我目前正在寻找使用一些 SQL Server SQL 代码编写一些单元测试tSQLt http://tsqlt.org.
阅读文档后,似乎不支持使用参数调用测试用例,而不是为每个参数组合编写单独的测试用例。(为了这个问题,请先搁置您是否认为将参数传递给测试用例是一个好主意,还是为每个参数组合编写一个单独的测试用例)
例如在NUnit http://nunit.org您可以使用以下命令执行以下操作TestCase https://github.com/nunit/docs/wiki/TestCase-Attribute属性:
[TestCase("", -1, false)]
[TestCase("ACT ", 1, true)]
[TestCase("ACT", 1, true)]
[TestCase("aCT", 1, true)]
[TestCase("AUSTRALIAN CAPITAL TERRITORY", 1, true)]
[Test]
public void DetermineStateIdFromText(string aStateText, long aExpectedStateId, bool aExpectedFound)
{
//Arrange
WzDetermineStateIdFromTextInput input = new WzDetermineStateIdFromTextInput
{
StateText = aStateText
};
//Act
WzDetermineStateIdFromTextOutput output = _WzLocationMappingService.DetermineStateIdFromText(input);
//Assert
output.ResultSuccess.ShouldBeTrue();
output.Found.ShouldBe(aExpectedFound);
if (output.Found)
{
output.StateId.ShouldBe(aExpectedStateId);
}
}
(测试方法的内部内容无关紧要,包含在内只是为了完整性。ShouldBe() 调用来自Shouldly https://github.com/shouldly/shouldly如果您想知道断言在哪里。)
有没有人有任何解决方案来在 tSQLt 中提供 TestCase 风格支持?