Set Up Test Method with different inputs

前端 未结 3 1290
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-08 01:45

I want to test the following method in C# for all code paths.

public int foo (int x)
{
    if(x == 1)
        return 1;
    if(x==2)
        return 2;
    else
          


        
3条回答
  •  囚心锁ツ
    2021-02-08 02:07

    In MS Test you can create data driven tests that accept different inputs for the same test method.

    Here's a blog post on it: http://toddmeinershagen.blogspot.ca/2011/02/creating-data-driven-tests-in-ms-test.html

提交回复
热议问题