【发布时间】:2022-01-18 09:37:49
【问题描述】:
假设我有这样的测试方法:
[TestMethod]
[DataRow( 0, 0, 0 )]
[DataRow( 0, 0, 1 )]
[DataRow( 0, 1, 0 )]
[DataRow( 0, 1, 1 )]
[DataRow( 1, 0, 0 )]
[DataRow( 1, 0, 1 )]
[DataRow( 1, 1, 0 )]
[DataRow( 1, 1, 1 )]
public void ReallyCoolTest( int a, int b, int c )
{
// some really cool test code that uses a, b, and c
}
这将针对等于 0 或 1 的 a、b 和 c 的所有组合进行测试。三个参数中只有两个值,并且需要 8 个 DataRow 行!
我真正想做的是这样的:
[TestMethod]
[DataMatrix( {0,1}, {0,1}, {0,1} )]
public void ReallyCoolTest( int a, int b, int c )
{
// some really cool test code that uses a, b, and c
}
我想为每个参数指定一些值并测试所有组合。使用 MS 测试有类似的东西吗?
注意:我知道DataSource 属性。但是,我希望将值放在代码中,而不是在外部文件中。
【问题讨论】: