-3

I am looking to run Nunit test but I do not want the tests to be data dependent. For eg: If I am running my unit test on testing server referring to testing database and if some user changes database values; it should not have an impact on my testing scenarios. However I want my testing scenarios to refer to oracle Stored procedures. Thanks....any help would be highly appreciated. Also I am open to the idea of any other tool which has the ability to achieve this.

1 Answers1

0

If you are really hitting the database this not a unit test but integration test.
Basically you have two options which one with it's pros and cons:

  1. Keep with the idea of integration tests but ensure somehow that the data you are using is as you expected.
    This can be achieved using stored procedure in your testing database that recreate your data while calling it, you can call this procedure in your tests initialization and then do all of your testing.
    The main disadvantage here is that the test will take more time than unit test and will cost more resources.
    The main advantage is that you can be sure you're code integrates well with your database.

  2. Choosing to use a real unit tests, in this option you will not going to use the database at all but instead create in-memory objects that represents the data from your database.
    Because you will create this objects in the arrange part of your unit test you can know extacly what data they are holding.
    The main disadvantage here is that you can't be sure you're code integrates well with your database.
    The main advantage is that the test will take less time than integeration test and will cost less resources, moreover your test can be run even if your testing database is down.

If you want you can actually choose to use both options, this is useful because each test is testing your code from a different perspective.

More about unit tests vs integeration tests can be found here.

Community
  • 1
  • 1
YuvShap
  • 3,735
  • 2
  • 8
  • 24