Fitnesse- Should tests talk to the database?
Asked Answered
L

5

7

We are trying to use Fitnesse for our Functional test. Should i be mocking dependencies or should it be testing against the database?

What are the Pros/Cons of either of the approach?

The whole issue of testing against the DB is setting up data which is huge dependency. If we mock then is it real functional test?

Thanks

Lunalunacy answered 25/1, 2010 at 18:32 Comment(0)
S
4

We have a full set of end to end functional tests that run in fitnesse in two modes: "InMemory" and "Database", Depending on which configuration to run the tests in dictates which repositories the tests use. This has several advantages:

1) It keeps the developers from building a lot of functionality into the database and keeps in in the code.

2) When "In-Memory" the fitnesse tests run very very fast. Allowing the tests to fail very very fast...and thus speed up development and agility. When they run in db mode only they do take some time.

Sammie answered 29/1, 2010 at 3:13 Comment(0)
Q
3

I see (at least) 2 types of tests that can be done with FitNesse:

  • Tests (or examples) intended to specify domain logic or behavior. These I tend not to use with database access as this is usually not important to the purpose of the test.

  • End-to-end (or nearly end-to-end) tests used as regression or smoke tests. These, obviously, include database functionality.

The benefit of including the DB is that the test is more representative of the actual production system, the drawback is the additional cost of setting up and managing database state. Look at DbFit, a set of fixtures designed to help with DB set-up and verification.

Qumran answered 25/1, 2010 at 21:13 Comment(0)
S
1

I'd rather isolate the integration tests involving the DB in NUnit. Your fonctional tests should not fail because to integration issues. I've found more comfortable to carry object states through simple singletons than DB.

Slowmoving answered 26/1, 2010 at 14:9 Comment(0)
C
0

I think it should test against the database. Because as you are doing functional test with fitnesse, you shoudnt be using mock. Use it with database to know the actual database functionality working fine or not as your DB will have a huge data.

Chartist answered 25/1, 2010 at 18:45 Comment(1)
Thanks. What about the pain of Setup data? Isn't that hard for each and every test case. We would want to use this part of CI. How easy or difficult it is in Fitnesse to setup data?Lunalunacy
P
0

I have worked on creating a different test suite for DB related stuff which gives me more confidence when I get into other functionality testing. Things like business rules, stored procs and some basic but important tables can be validated to make sure they are where they suppose to be and rendering right results. If that's as expected then what you see on front end should be a solid environment to do functionality tests

Piled answered 26/1, 2010 at 20:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.