Any solutions to getting Nunit style TestCase() functionality in tSQLt?

前端 未结 1 987
情书的邮戳
情书的邮戳 2020-12-22 11:35

I am currently looking to write some unit tests for some SQL Server SQL code using tSQLt.

After reading the docs it appears that there is no support for being able t

相关标签:
1条回答
  • 2020-12-22 12:01

    tSQLt allows the use of stored procedures that are not test cases within test classes. So to achieve, what you are looking for, I usually create a stored procedure that accepts parameters and handles all the test logic. Then I write a bunch of single line test procedures that call the other procedure passing in the appropriate parameters. There are a few examples for this in the test cases for tSQLt itself.

    This approach has very few disadvantages over truly parameterized tests, but one big advantage: You can give each case a truly meaningful name that will make hunting down issues a lot simpler. (True parameterized tests are on the backlog, but they are not the highest priority, so it might be a while for them to make it.)

    As a side note, I strongly advise against autogenerating tests or even parameters for tests, as that usually leads to higher maintenance costs. As the goal of testing is to reduce the cost of maintaining your codebase, that is counterproductive. I've seen a lot of unit testing adoption projects fail because of that very reason.

    0 讨论(0)
提交回复
热议问题