Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Serenity 3.2.4][Junit5]: Issue while generating output JSON When display name too long and contains special characters #2803

Closed
bachhavdipak opened this issue Apr 28, 2022 · 12 comments

Comments

@bachhavdipak
Copy link
Contributor

I am facing an issue while generating output JSON under target/site/serenity with special char and also observed there is a character limit while passing data through @DisplayName.

package starter.wikipedia;

import net.serenitybdd.core.Serenity;
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import net.thucydides.core.annotations.Managed;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.WebDriver;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(SerenityJUnit5Extension.class)
@DisplayName("JUnit 5 Nested Example")
class WhenSearchingForTerms {

    /**
     * Define the webdriver instance to be used for these tests
     */
    @Managed(driver = "chrome", options = "")
    WebDriver driver;

    /**
     * Navigation actions. This is a UIInteraction class so it will be instantiated automatically by Serenity.
     */
    NavigateActions navigate;

    /**
     * Actions related to searches. This is a UIInteraction class so it will be instantiated automatically by Serenity.
     */
    SearchActions search;

    /**
     * A page object representing a Wikipedia article that is currently appearing in the browser.
     * Page Objects are automatically initialised by Serenity.
     */
    DisplayedArticle displayedArticle;

    // SearchActions search;

    @Test
    @DisplayName("count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ % ^ & _ . % ^ & ( )  _ + * count can purchase some contact lenses then retrieve the order and perform store credential check")
    void count_can_purchase_some_contact_lenses_then_retrieve_the_order_and_perform_store_credential_check() {

        navigate.toTheHomePage();
        search.searchBy("Everest");
        Serenity.reportThat("The first heading should be 'Mount Everest'",
                () -> assertThat(displayedArticle.getFirstHeading()).isEqualTo("Mount Everest")
        );
    }
}

Generated jsn file under target/site/serenity/

image

Output Json:
{"name":"count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ ","id":"starter.wikipedia.WhenSearchingForTerms:count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ ","testCaseName":"starter.wikipedia.WhenSearchingForTerms","testSteps":[{"number":1,"description":"Navigate to the home page","duration":13042,"startTime":"2022-04-28T21:26:08.661+01:00[Europe/London]","screenshots":[{"screenshot":"d766ead5fa01902c43be6987673597ff3933826d50b64c72d7bbd153ebd0b126.png","timeStamp":1651177581702,"screenshotName":"d766ead5fa01902c43be6987673597ff3933826d50b64c72d7bbd153ebd0b126.png"}],"result":"SUCCESS","precondition":false,"level":0},{"number":2,"description":"Search by keyword \u0027Everest\u0027","duration":3691,"startTime":"2022-04-28T21:26:21.712+01:00[Europe/London]","screenshots":[{"screenshot":"21c27021c7e1fbdb3dad65225523477df21af28f8b92b19bf45630dfb981cd21.png","timeStamp":1651177585403,"screenshotName":"21c27021c7e1fbdb3dad65225523477df21af28f8b92b19bf45630dfb981cd21.png"}],"result":"SUCCESS","precondition":false,"level":0},{"number":3,"description":"The first heading should be \u0027Mount Everest\u0027","duration":1628,"startTime":"2022-04-28T21:26:25.403+01:00[Europe/London]","screenshots":[{"screenshot":"21c27021c7e1fbdb3dad65225523477df21af28f8b92b19bf45630dfb981cd21.png","timeStamp":1651177585997,"screenshotName":"21c27021c7e1fbdb3dad65225523477df21af28f8b92b19bf45630dfb981cd21.png"}],"result":"SUCCESS","precondition":false,"level":0}],"userStory":{"id":"starter.wikipedia.WhenSearchingForTerms","storyName":"When searching for terms","displayName":"JUnit 5 Nested Example","storyClassName":"starter.wikipedia.WhenSearchingForTerms","path":"wikipedia","type":"story"},"featureTag":{"name":"Wikipedia/When searching for terms","type":"story","displayName":"Wikipedia/When searching for terms"},"title":"count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ [ ^ \u0026 _ . ]","tags":[{"name":"Wikipedia/When searching for terms","type":"story","displayName":"JUnit 5 Nested Example"},{"name":"Wikipedia","type":"feature","displayName":"Wikipedia"}],"startTime":"2022-04-28T21:26:07.484+01:00[Europe/London]","duration":19580,"projectKey":"","sessionId":"6ad0ed5814a5f65ad7d6fc10a2b68f6f","driver":"chrome","isManualTestingUpToDate":false,"qualifier":" ^ \u0026 _ . ","manual":false,"testSource":"JUnit5","result":"SUCCESS"}

@wakaleo
Copy link
Member

wakaleo commented Apr 28, 2022

What is the issue?

@bachhavdipak
Copy link
Contributor Author

bachhavdipak commented Apr 28, 2022

If you observed the above JSON file then JSON is not generated as per the display name provided in the test.

@DisplayName("count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ % ^ & _ . % ^ & ( ) _ + * count can purchase some contact lenses then retrieve the order and perform store credential check")

Expected JSON :

"name":"count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ % ^ & _ . % ^ & ( ) _ + * count can purchase some contact lenses then retrieve the order and perform store credential check","id":"starter.wikipedia.WhenSearchingForTerms:count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ % ^ & _ . % ^ & ( ) _ + * count can purchase some contact lenses then retrieve the order and perform store credential check ","testCaseName":"starter.wikipedia.WhenSearchingForTerms","testSteps":....

Actual JSON :

{"name":"count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $ ","id":"starter.wikipedia.WhenSearchingForTerms:count can purchase some contact lenses then retrieve the order and perform store credential check ! $ $......

Also, you can check the screenshot for your reference JSON file name should be as per the display name

@wakaleo
Copy link
Member

wakaleo commented May 3, 2022

OK, I will take a look.

The JSON file name is a normalised form, it is not intended for human consumtion (the uncompressed format is only intended for debugging purposes).

@bachhavdipak
Copy link
Contributor Author

Hi @wakaleo no I am not talking about the JSON file name. Please check expected results section. Serenity doesn't seem to support display name properly. Also I have observed that JSON generated does not contain display name which is major change in junit5.

@bachhavdipak
Copy link
Contributor Author

Also observed junit 4.xx is also part of the serenity-junit5

@bachhavdipak
Copy link
Contributor Author

Any update on this why serenity junit 5 still referring junit 4 ?

@wakaleo
Copy link
Member

wakaleo commented Mar 29, 2023

There are no direct dependencies on JUnit 4 in the compile-scope dependencies of serenity-junit5.

@bachhavdipak
Copy link
Contributor Author

But while producing results seems like its not using junit 5. I can see public interface DisplayNameGenerator is not supported using serenity junit 5

@bachhavdipak
Copy link
Contributor Author

bachhavdipak commented Mar 29, 2023

I raised this bug last year April 2022 but looks like its not resolved . I can still see this with serenityCoreVersion = 3.6.21

@wakaleo
Copy link
Member

wakaleo commented Mar 29, 2023

Here is an example of a Serenity BDD test that uses the DisplayNameGenerator:

@ExtendWith(SerenityJUnit5Extension.class)
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
public class JUnit5GeneratedExample {

    @Test
    void sample_test() {
    }

    @Nested
    class Nested_Test_Cases {

        @Test
        void sample_nested_test() {
        }
    }
}

@wakaleo
Copy link
Member

wakaleo commented Mar 29, 2023

I raised this bug last year April 2022 but looks like its not resolved . I can still see this with serenityCoreVersion = 3.6.21

There is no SLA on open source defects. If a bug or feature has value for your organisation, you can (a) wait for a volunteer to spend their personal time to implement it, (b) implement it yourself (or pay someone to implement it) and raise a pull request, or (c) purchase a commercial support package in order to see it implemented more quickly. If you would like to know about the third option, let me know and I can send you some details.

@bachhavdipak
Copy link
Contributor Author

Ahh i thought its based on open defects raised in the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants