2017-02-22 22 views
1

我需要獲取大量參數才能動態構建測試方法。我的限制是它必須在MSTest和C#中。在集成測試中獲取參數MSTesting C#

我在想什麼是喜歡的東西:

[TestMethod] 
public void test1 (int x, int y, string url, double l) 
{ 
    // Use parameters here 
} 

我知道這是不可能的,我明白了。但那最終是我需要得到的。

任何人都可以分享一些見解嗎?

回答

0

MSTest V2你可以使用DataRowAttribute來做到這一點。例如:

[TestMethod] 
[DataRow(1, 2, "http://kuku.com", 3.4)] 
[DataRow(4, 5, "http://foo.com", 6.7)] 
public void test1 (int x, int y, string url, double l) 
{ 
    // Use parameters here 
} 

這將導致測試對於每組由對應DataRowAttribute指定的值的運行兩次,一次。