Unit test method with many possible results

I built a simple ~ ish method that creates a URL of about 5 parts: base address, port, path, "action" and a set of parameters. Of these, only part of the address is mandatory, the remaining parts are optional. A valid URL must exit the method for each permutation of the input parameters, for example:

  • the address
  • address port
  • address port
  • address path
  • address action
  • path address action
  • address port action
  • Port Address Path Action
  • address action parameters
  • Path Path Action Parameter
  • port port action parameters
  • Port port path action parameter

andsoforth. , unit test , unit test, , .

, , (tm) ? () unit test ?

(rant) , -, (, ), , unit test , , , . , , , yanno. . (/)

( ) , , . (/)

+3
1

, , , . NUnit Testing Framework, , .

[TestCase("http://www.url.com")]
[TestCase("http://www.url.com", 21)]
[TestCase("http://www.url.com", 24, @"c:\path")]
public void TestingMethod(string address, params object[] address) {
    // Do your tests accordingly here...
}

, TestCaseAttribute ( NUnit), .

, , . object[], , , , , .

+2

Source: https://habr.com/ru/post/1781998/


All Articles