johanmoritz / freecol

FreeCol: FreeCol is a turn-based strategy game based on the old game Colonization, and similar to Civilization. The objective of the game is to create an independent nation.
GNU General Public License v2.0
0 stars 1 forks source link

Implement branch coverage by manual instrumentation, Unit::setLocation #23

Closed Kappenn closed 4 years ago

Kappenn commented 4 years ago

Implement branch coverage by manual instrumentation of the source code for ten functions, Do this for: Unit::setLocation@4090-4153@./src/net/sf/freecol/common/model/Unit.java See 3.5.1 in task pdf

adbjo commented 4 years ago

Has 93% coverage according to OpenClover.

johanmoritz commented 4 years ago

Resolved by f7df84e.

adbjo commented 4 years ago

Each if statement should be followed by an else statement, so that we can call CodeCoverage in both branches. CodeCoverage calls can, and should, be added after loops:

while(cond) {
    CodeCoverage.run("example");
    // do something
}
CodeCoverage.run("example");

But not after if statements (except in else statements). "Before the first statement of each branch outcome, (including to-be-added "else" clauses if none exists)..." - from task.pdf.

johanmoritz commented 4 years ago

Good catch! Thank you :)

adbjo commented 4 years ago

No problem, I went ahead and fixed it in 4dc11fa14d94c42a6bb0020a01ff58d4653a0da5. Forgot to mention it here.

johanmoritz commented 4 years ago

Great!