English 中文(简体)
以不同的值测试函数
原标题:To test the function with different values

我有测试功能:

[TestMethod()]
public void CreateTest(string input)
{
   string expected = "321"; 
   Assert.AreEqual(expected, input);
}

I need to run this test with different data: CreateTest("321"); CreateTest("123"); CreateTest(null); I do not know how to do this before I did something like [TestCase("123")], [TestCase("321")]

我需要的东西:

[RowTest]
[Row(1,1,2)]
[Row(2,1,3)]
[Row(1,-1,0)]
public void SumTest(int a1, int a2, int result)
{
    Assert.AreEqual(a1 + a2, result);
}
最佳回答

您是否尝试过 < a href=> http://msdn.microsoft.com/ en- us/library/ms182527%28v=vs. 100%29. aspx" rel=“ nofollow” > data- help 单位测试 ? 它没有使用类属性, 但应该给您同样的结果 。

如果您想要达到 < 坚固> 高代码覆盖 , 请使用 < a href=" "http://research.microsoft.com/ en- us/projects/pex/" rel="nofollow" 查看 Pex power 工具 。

如果您想要“强势”模拟您的测试 (<强势a href=""http://en.wikipedia.org/wiki/Model-based_controduction" rel=“nofollow”>>MBT , >specExplorer 也值得审查

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签