How to write tests that escapes or bypasses few methods and conditions inside a big method that is being tested.
For example, I have this method below:
public bool IsValid(int id)
{
var details = _myService.GetDetails(id); // This line should be avoided in test
var doctorDetails = _myService.GetDoctorDetails("AUS"); // This needs to be executed
if(details.Name == "Ab") // This if I dont want to be part of my test
{
// Do something
}
if(doctordetails !=null)
{
// Code to test
}
}
Aucun commentaire:
Enregistrer un commentaire