Reputation: 9116
Consider I have a Method M()
which will be called during execution of Tests T1()
and T2()
.
Is there a way to find out that M
will be executed in T1
and T2
?
I know that it would be impossible to find it out through the code. But using history of Unit Test's executions is good too.
Upvotes: 1
Views: 119
Reputation: 8358
OpenCover (also available via nuget) has this as a feature -coverbytest
, the results of which can be visualized using ReportGenerator.
Upvotes: 4
Reputation: 6553
NCrunch is a great testing tool (paid) which shows test coverage (including in those methods) inline and in reporting (metrics).
NSubstitute (and others) allow you to do checks such as .Recieved()
that allow you to specific both arguments expected and how many times you expected it to be called (or not called!)
http://nsubstitute.github.io/help/received-calls/
[Test]
public void Should_execute_command_the_number_of_times_specified() {
var command = Substitute.For<ICommand>();
var repeater = new CommandRepeater(command, 3);
//Act
repeater.Execute();
//Assert
command.Received(3).Execute(); // << This will fail if 2 or 4 calls were received
}
Upvotes: 1