I've been tasked to implement unit tests for a lot of modules in a firm and the only Problem I've encountered so far is for Methods where they have about 20 Input Variables and 15 Output variables. How do I even check for so many possibilities?
CodePudding user response:
Well, i guess then method looks something like this:
public Output Process(T1 input1, ..., T20 input20) { ... }
where Output
would be
public class Output
{
public OutputT1 Output1 { get; set; }
...
public OutputT15 Output15 { get; set; }
}
So your test method could look like this:
[Fact]
public void TestProcessing()
{
// Arrange
var input1 = new T1(); // set some appropriate data
...
var input20 = new T20(); // set some appropriate data
// Also set expected values
var actualOutput1 = new OutputT1();
...
var actualOutput15 = new OutputT15();
// Act
var output = _sut.Process(input1, ..., input20);
// Assert
Assert.Equals(output.Output1, actualOutput1);
...
Assert.Equals(output.Output15, actualOutput15);
}
CodePudding user response:
An example would be a method looking like this:
public void Process()
{
//Input
int1;
int2;
int3;
int4;
int5;
.....
//Calculations
.....
//Output
string1;
string2;
Int3;
double4;
}
Since all the Methods are given and am not allowed to change, would that mean that I need to do 4x expected and 4x actual variables? Meaning I need 4x Asserts for every Test?