I write some unit tests and I want to avoid duplicate code. Say I have a Scenario1 defined in the following way:
SCENARIO("Scenario1") {
cfg config;
config.field = 0;
GIVEN("something_1") {
WHEN("event_1") {
//block_code_1
}
WHEN("event_2") {
//block_code_2
}
WHEN("event_3") {
//block_code_3
}
}
}
Now, Scenario2 is the same as Scenario1, but config.field = 1 and block_code_1 and block_code_2 are the same except for block_code_3 which is different in Scenario2.
So my question is: what is the best practice to do unit-testing in this case ?
Aucun commentaire:
Enregistrer un commentaire