JGiven icon indicating copy to clipboard operation
JGiven copied to clipboard

reporting test scenario with multiple cases

Open adrian-herscu opened this issue 2 years ago • 7 comments

Sometimes cases are rendered as a table and sometimes the scenario is repeated for each case. Any suggestion(s) about how to control this behavior?

adrian-herscu avatar Jan 24 '23 19:01 adrian-herscu

Does that actually happen at random? 😦 Because test cases should always render as table...

l-1squared avatar Jan 26 '23 05:01 l-1squared

    @DataProvider(parallel = true)
    public static Object[][] cutoffTimesPerNetwork() {
        return new Object[][] {
            { "Star", LocalTime.of(16, 59, 59) },
            { "NYCE", LocalTime.of(14, 29, 59) },
            { "Pulse", LocalTime.of(23, 59, 59) },
           ...
        };
    }

    @Reference("882016")
    @Test(dataProvider = "cutoffTimesPerNetwork")
    // ISSUE see https://github.com/TNG/JGiven/issues/1173
    public void shouldAllowAfterNetworkCutoffTransaction(
        final String network,
        final LocalTime cutoffTime) {
        given()
         ...

Is rendered like this: image

adrian-herscu avatar Jan 26 '23 07:01 adrian-herscu

Found that there was a @CasesAsTable annotation -- https://github.com/TNG/JGiven/blob/master/CHANGELOG.md

In my report JSON it appears like this: image

adrian-herscu avatar Feb 01 '23 06:02 adrian-herscu

Interesting. I will have a look at that once I got that java 11 upgrade going. Those broken PRs bother me a lot.

l-1squared avatar Feb 02 '23 06:02 l-1squared

Hi @adrian-herscu , so I have found this neat little method https://github.com/TNG/JGiven/blob/5419a0ac7d3682ccb6109ef93a6706f5dc25ab11/jgiven-core/src/main/java/com/tngtech/jgiven/report/analysis/CaseArgumentAnalyser.java#L49 I would assume that it may be the culprit for setting that value erroneously. Could you support me by providing the actual test case that produces the udesired behavior (or an equivalent abstraction). Please note that the CaseArgument analyzer wants the amount of words to be equal, the number of attachemnts to be comparable, the words to be the same and the steps to be equal.

l-1squared avatar Feb 09 '23 05:02 l-1squared

Hi @adrian-herscu could you please provide additional informaition on the subject? Otherwise I'll have to close this issue as there is nothing with which I can help.

l-1squared avatar Feb 21 '23 06:02 l-1squared

In same project I have a test class which is reported as a table while others are reported as separated cases. Unfortunately, I have not enough time now to simplify them as you would expect :( You may close this issue for now, and when, and if, it will become critical for me then I will get back to it.

This one produces a table: https://github.com/QA-Automation-Starter/qa-automation/blob/main/qa-testing-example/src/test/java/dev/aherscu/qa/testing/example/scenarios/tutorial3/TestingWebWithJGiven.java

However, it derives from other class. Its steps are also deriving from other classes. So producing a clean example is not a one minute task.

The other test classes which report separate cases look similar but work over REST. They are part of my current work project, so even harder to cleanup :(

adrian-herscu avatar Feb 21 '23 10:02 adrian-herscu