@ParameterizedTest(name = "Generates programs for {0} grammar with top rule {1}")
@MethodSource("syntax")
void generatesSyntaxForGrammar(
final List<String> definitions,
final String top,
@TempDir final Path temp
) {
final Input[] grammars = definitions.stream().map(ResourceOf::new)
.toArray(Input[]::new);
final RandomScript script = new RandomScript(grammars);
final SyntaxGuard guard = new SyntaxGuard(temp, top, grammars);
final String message =
"We expect that the randomly generated code will be verified without errors";
try {
Assertions.assertDoesNotThrow(
() -> Stream.generate(() -> top)
.map(script::generate)
.limit(50)
.peek(SyntaxGenerationIT::logProgram)
.forEach(guard::verifySilently),
message
);
} catch (final IllegalTextException exception) {
exception.saveDot();
Assertions.fail(message, exception);
}
}
As you can see, there are several assertion statements, but jtcop complains that there is none:
[ERROR] Failed to execute goal com.github.volodya-lombrozo:jtcop-maven-plugin:1.2.4:check (default) on project jsmith:
[ERROR] The test class SyntaxGenerationIT.java (/Users/lombrozo/Workspace/OpenSource/jsmith/src/test/java/com/github/lombrozo/jsmith/it/SyntaxGenerationIT.java:) has encountered some problems. Please review the results for more information.
[ERROR] 1) Method generatesSyntaxForGrammar doesn't have assertion statements.
[ERROR] Please add at least one assertion statement to the test method.
[ERROR] You can also ignore the rule by adding @SuppressWarnings("JTCOP.RuleAssertionMessage") annotation.
[ERROR] Rule: RuleAssertionMessage.
[ERROR] You can read more about the rule here: https://github.com/volodya-lombrozo/jtcop/blob/main/docs/rules/no-assertions.md
I have this code in one of the projects:
As you can see, there are several assertion statements, but
jtcop
complains that there is none: