-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[code+test] fix an issue where a pair of stepped literal and the step…
… definition got the first difference from the parameter, a hard error is thrown. should close #12
- Loading branch information
Showing
10 changed files
with
207 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/java/scs/comp5903/cucumber/sample/pirates/BugFixedFromIssueBoardTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package scs.comp5903.cucumber.sample.pirates; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import scs.comp5903.cucumber.EasyCucumber; | ||
import scs.comp5903.cucumber.model.exception.EasyCucumberException; | ||
import scs.comp5903.cucumber.util.ResourceUtil; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* This test class is used to verify the bug fixed from the issue board from GitHub repo | ||
* @author CX无敌 | ||
* @date 2022-10-26 | ||
*/ | ||
class BugFixedFromIssueBoardTest { | ||
|
||
@Test | ||
void check1() { | ||
assertDoesNotThrow(() -> EasyCucumber.build(ResourceUtil.getResourcePath("sample/jfeature/pirates/mismatch-bug.jfeature"), MismatchBugStepDef.class).executeAll()); | ||
} | ||
|
||
@Test | ||
void checkIssue12() { | ||
assertDoesNotThrow(() -> EasyCucumber.build(ResourceUtil.getResourcePath("sample/jfeature/pirates/similar-step.jfeature"), SimilarStepBugStepDef.class).executeAll()); | ||
var easyCucumberException = assertThrows(EasyCucumberException.class, () -> EasyCucumber.build(ResourceUtil.getResourcePath("sample/jfeature/pirates/similar-step.jfeature"), SimilarStepBugStepDefWithFailure.class)); | ||
assertTrue(easyCucumberException.getMessage().contains("Step definition not found for: AndStep(stepString='Player3' gets disqualified)")); | ||
} | ||
} |
18 changes: 12 additions & 6 deletions
18
src/test/java/scs/comp5903/cucumber/sample/pirates/MismatchBugStepDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
package scs.comp5903.cucumber.sample.pirates; | ||
|
||
import org.slf4j.Logger; | ||
import scs.comp5903.cucumber.model.annotation.JAndStep; | ||
import scs.comp5903.cucumber.model.annotation.JGivenStep; | ||
import scs.comp5903.cucumber.model.annotation.JThenStep; | ||
import scs.comp5903.cucumber.model.annotation.JWhenStep; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* @author CX无敌 | ||
* @date 2022-10-26 | ||
*/ | ||
public class MismatchBugStepDef { | ||
|
||
private static final Logger log = getLogger(MismatchBugStepDef.class); | ||
|
||
@JGivenStep("The game starts with {int} player") | ||
public void theGameStartsWithPlayer(int numPlayers){ | ||
System.out.println("The game starts with " + numPlayers + " player"); | ||
log.debug("The game starts with " + numPlayers + " player"); | ||
} | ||
|
||
@JAndStep("The player names are the following {string}") | ||
public void thePlayerNamesAreTheFollowing(String nameStr){ | ||
System.out.println("The player names are the following " + nameStr); | ||
log.debug("The player names are the following " + nameStr); | ||
} | ||
|
||
@JWhenStep("{string} gets {string} fortune card") | ||
public void playerGetsFortuneCard(String playerName, String card) { | ||
System.out.println(playerName + " gets " + card + " fortune card"); | ||
log.debug(playerName + " gets " + card + " fortune card"); | ||
} | ||
|
||
@JAndStep("{string} rolls the following {string}") | ||
public void playerRollsTheFollowing(String playerName, String rollStr) { | ||
System.out.println(playerName + " rolls the following " + rollStr); | ||
log.debug(playerName + " rolls the following " + rollStr); | ||
} | ||
|
||
@JAndStep("Player scores are the following {string}") | ||
public void playerScoresAreTheFollowing(String expectedStrScores) { | ||
System.out.println("Player scores are the following " + expectedStrScores); | ||
log.debug("Player scores are the following " + expectedStrScores); | ||
} | ||
|
||
@JThenStep("{string} gets disqualified") | ||
public void playerGetsDisqualified(String playerName) { | ||
System.out.println(playerName + " gets disqualified"); | ||
log.debug(playerName + " gets disqualified"); | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/test/java/scs/comp5903/cucumber/sample/pirates/MismatchTest.java
This file was deleted.
Oops, something went wrong.
41 changes: 41 additions & 0 deletions
41
src/test/java/scs/comp5903/cucumber/sample/pirates/SimilarStepBugStepDef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package scs.comp5903.cucumber.sample.pirates; | ||
|
||
import org.slf4j.Logger; | ||
import scs.comp5903.cucumber.model.annotation.JAndStep; | ||
import scs.comp5903.cucumber.model.annotation.JGivenStep; | ||
import scs.comp5903.cucumber.model.annotation.JThenStep; | ||
import scs.comp5903.cucumber.model.annotation.JWhenStep; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* @author CX无敌 | ||
* @date 2022-10-26 | ||
*/ | ||
public class SimilarStepBugStepDef { | ||
private static final Logger log = getLogger(SimilarStepBugStepDef.class); | ||
@JGivenStep("Test given") | ||
public void given() { | ||
log.debug("Test given"); | ||
} | ||
|
||
@JWhenStep("Test when") | ||
public void when() { | ||
log.debug("Test when"); | ||
} | ||
|
||
@JThenStep("Test then") | ||
public void then() { | ||
log.debug("Test then"); | ||
} | ||
|
||
@JAndStep("{string} gets {string} fortune card") | ||
public void andTest(String player, String card) { | ||
log.debug(player + " gets " + card + " fortune card"); | ||
} | ||
|
||
@JAndStep("{string} gets disqualified") | ||
public void disqualified(String player) { | ||
log.debug(player + " gets disqualified"); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/scs/comp5903/cucumber/sample/pirates/SimilarStepBugStepDefWithFailure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package scs.comp5903.cucumber.sample.pirates; | ||
|
||
import org.slf4j.Logger; | ||
import scs.comp5903.cucumber.model.annotation.JAndStep; | ||
import scs.comp5903.cucumber.model.annotation.JGivenStep; | ||
import scs.comp5903.cucumber.model.annotation.JThenStep; | ||
import scs.comp5903.cucumber.model.annotation.JWhenStep; | ||
|
||
import static org.slf4j.LoggerFactory.getLogger; | ||
|
||
/** | ||
* Similar to {@link SimilarStepBugStepDef}, but with a mismatch in the {@link #disqualified(String)} method. | ||
* @author CX无敌 | ||
* @date 2022-10-26 | ||
*/ | ||
public class SimilarStepBugStepDefWithFailure { | ||
private static final Logger log = getLogger(SimilarStepBugStepDefWithFailure.class); | ||
@JGivenStep("Test given") | ||
public void given() { | ||
log.debug("Test given"); | ||
} | ||
|
||
@JWhenStep("Test when") | ||
public void when() { | ||
log.debug("Test when"); | ||
} | ||
|
||
@JThenStep("Test then") | ||
public void then() { | ||
log.debug("Test then"); | ||
} | ||
|
||
@JAndStep("{string} gets {string} fortune card") | ||
public void andTest(String player, String card) { | ||
log.debug(player + " gets " + card + " fortune card"); | ||
} | ||
|
||
@JAndStep("{string} is disqualified") | ||
public void disqualified(String player) { | ||
log.debug(player + " is disqualified"); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/test/resources/sample/jfeature/pirates/mismatch-bug.jfeature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.