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

@BeforeAll Tag is not triggering while running from terminal(serenity version 3.1.20) #2688

Closed
sandlok opened this issue Feb 3, 2022 · 11 comments

Comments

@sandlok
Copy link

sandlok commented Feb 3, 2022

Hi All,
I am using latest serenity version with Cucumber 7 to use BeforeAll tag. This Tag is running fine when executing the test scenarios from feature file. However when executing the scenarios from terminal(mvn clean install) the @BeforeAll tag is not working. Please advise.

My Pom file


4.0.0
org.example
ExampleAutomation
0.0.1-SNAPSHOT
jar

 <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <serenity.core.version>3.1.20</serenity.core.version>
        <serenity.cucumber6.version>${serenity.core.version}</serenity.cucumber6.version>
        <serenity-rest-assured.version>${serenity.core.version}</serenity-rest-assured.version>
        <serenity-maven-plugin.version>${serenity.core.version}</serenity-maven-plugin.version>
        <serenity-jira-plugin.version>1.12.0</serenity-jira-plugin.version>
        <groovy-all.version>3.0.8</groovy-all.version>
        <slf4j-simple.version>1.7.9</slf4j-simple.version>
        <assertj-core.version>3.20.2</assertj-core.version>
        <commons-net.version>3.3</commons-net.version>
        <aspectj.version>1.9.7</aspectj.version>
        <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
        <json-unit.version>2.27.0</json-unit.version>
        <parallel.tests>3</parallel.tests> 
        <junit.version>5.6.0</junit.version>
		<junit.jupiter.version>${junit.version}</junit.jupiter.version>
		<junit.vintage.version>${junit.version}</junit.vintage.version>
		<junit.platform.version>1.6.0</junit.platform.version>
      </properties>
	 <repositories>
   	 <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray</name>
        <url>https://jcenter.bintray.com</url>
   	 </repository>
 	 </repositories>
	 <pluginRepositories>
   	 <pluginRepository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>bintray-plugins</name>
        <url>https://jcenter.bintray.com</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>
    <dependency>
        <groupId>com.github.javafaker</groupId>
        <artifactId>javafaker</artifactId>
        <version>0.15</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.9</version>
    </dependency>
    <dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
	</dependency>
    
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.9.9</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>2.9.9</version>
    </dependency>
   	 <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.10</version>
        <scope>provided</scope>
    </dependency>

	 <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.0.13</version>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-core</artifactId>
        <version>${serenity.core.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
     <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-cucumber</artifactId>
        <version>${serenity.core.version}</version>
        <scope>test</scope>
    </dependency>
    
   <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-junit</artifactId>
        <version>${serenity.core.version}</version>
        <scope>test</scope>
    </dependency> 
  			  <dependency>
		 <groupId>org.junit.jupiter</groupId>
		<artifactId>junit-jupiter-api</artifactId>
		 <version>5.8.2</version>
		 <scope>test</scope>
			</dependency>
    
    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>3.6.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>net.serenity-bdd</groupId>
        <artifactId>serenity-rest-assured</artifactId>
        <version>${serenity.core.version}</version>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>1.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>4.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.github.fge</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
			<groupId>io.cucumber</groupId>
			<artifactId>cucumber-java8</artifactId>
			 <version>7.0.0</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			 <groupId>io.cucumber</groupId>
			  <artifactId>cucumber-junit</artifactId>
			 <version>7.0.0</version>
			 <scope>test</scope>
		</dependency>
   
		 </dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                 <testFailureIgnore>true</testFailureIgnore>
                <skip>false</skip>
                 <includes>
                    <include>CucumberTestSuite.java</include>
                </includes>
            </configuration>
        </plugin> 
        <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
                <includes>
                    <include>**/*TestSuite.java</include>
                </includes>
             	 <threadCount>${parallel.tests}</threadCount> 
            	  <forkCount>${parallel.tests}</forkCount>
             	  <parallel>methods</parallel>   
   				<useUnlimitedThreads>true</useUnlimitedThreads>  
                <systemPropertyVariables>
                <report>true</report>
                <environment>{environment}</environment>
                </systemPropertyVariables>
      	   </configuration> 
            <executions>
                <execution>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.0</version>
            <configuration>
                <source>11</source>
                <target>11</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>net.serenity-bdd.maven.plugins</groupId>
            <artifactId>serenity-maven-plugin</artifactId>
            <version>${serenity.core.version}</version>
             <configuration>
        				 <tags>${tags}</tags>
        				  <reports>single-page-html</reports> 
    		</configuration>
            <executions>
                <execution>
                    <id>serenity-reports</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>aggregate</goal>
                    </goals>
                     <configuration>
                 
             	 </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
@wakaleo
Copy link
Member

wakaleo commented Feb 3, 2022

You can't run Serenity tests directly from the feature file. Looks like your pom.xml has some dependency conflicts - resolve these and see if the problem persists.

@sandlok
Copy link
Author

sandlok commented Feb 4, 2022

@wakaleo I have tried again with resolving conflicts in Pom. Still @BeforeAll code is not triggering from terminal(mvn clean install)

@wakaleo
Copy link
Member

wakaleo commented Feb 4, 2022

It looks like BeforeAll and AfterAll are not supported by versions of Cucumber 7 before 7.2.1. This will be included in the standard Serenity dependencies in versions 3.2.0 onwards.

@jakimcho
Copy link

jakimcho commented Feb 5, 2022

Hi @wakaleo I'm also experiencing the same Problem. the hooks @BeforeAll and @afterall are not executed when run with serenity and cucumber 7
I have created a simple project that logs messages on defferent cucumber Hooks: https://github.com/jakimcho/SerenityCucumber7
There are three branches and only the one with Cucumber 7.1.0 without serenity, logs messages from the @BeforeAll and @afterall hooks.

@wakaleo
Copy link
Member

wakaleo commented Feb 5, 2022

See my previous comment.

@jakimcho
Copy link

jakimcho commented Feb 6, 2022

I saw it. Just wanted to point out that my plain cucumber project uses a cucumber version before 7.2.1 and the hooks work as expected.

@wakaleo
Copy link
Member

wakaleo commented Feb 6, 2022

@jakimcho OK, thanks. I knew this was introduced in 7.2.1 or earlier, but didn't know the precise version.

@sandlok
Copy link
Author

sandlok commented Feb 7, 2022

@wakaleo when is the new serenity release planned(3.2.0)

@sandlok
Copy link
Author

sandlok commented Feb 7, 2022

@jakimcho I see what you mean. I did execute the projects what ever you had mentioned in the link and observed the logs statements. only one with cucumber dependencies without serenity projects are executing @BEFOREALL @afterall

@wakaleo
Copy link
Member

wakaleo commented Feb 7, 2022

@wakaleo when is the new serenity release planned(3.2.0)

When it is ready.

@sandlok
Copy link
Author

sandlok commented Feb 7, 2022

@wakaleo when is the new serenity release planned(3.2.0)

When it is ready.

Ok.Thanks

wakaleo added a commit that referenced this issue Feb 14, 2022
* PageElements can now be used in Action Classes

* PageElements can now be used in Action Classes

* Removed old datatable files to fix #2667.

* Improved support for aria-labels in the PageElement components.

* Fixed a broken unit test.

* Minor refactoring.

* Minor test refactoring

* Unit test fixes

* Added better reporing on the number of test cases vs the number of scenarios

* Fixed #2660

* Minor refactoring

* Updated to appium 8.0.0-beta2

* fixed syntax error in pom file

* minor refactoring

* [ci skip] prepare release 3.1.16

* [ci skip] prepare for next development iteration

* [maven-release-plugin] rollback the release of 3.1.16

* [ci skip] prepare release 3.1.16

* [maven-release-plugin] rollback the release of 3.1.16

* [ci skip] prepare release 3.1.16

* [ci skip] prepare for next development iteration

* Added possessive pronouns to Screenplay defaults

* Fixed an error in reporting test duration statistics with data-driven tests

* Minor refactoring

* Minor performance improvements

* Extend Playwright integration (#2681)

* Refactor Playwright screenshot.

* Implement screenshots for SERENITY_TAKE_SCREENSHOTS: FOR_FAILURES and FOR_EACH_ACTION.

* Update return classes for Open action.

* Add Playwright actions to open page from class.
Divide Playwright questions and add methods to get text of multiple matching elements.

* Use LOGGER.debug instead of System.out.println and fix NPE in BrowseTheWebWithPlaywright.

* Use ScreenshotPermission instead of hardcoded screenshot levels for Playwright.

* Upgrade Playwright.
Implement SelectFromOptions interaction.

* Implement Select interactions by index and visible text for Playwright.

* Implement Ensure.currentValue to check current vales of input, textarea and select.

* Update Javadoc

* Implement Attribute question.

* Implement SelectOptions and Visibility questions.

Co-authored-by: Serghei Pogodin <serghei.pogodin@rabobank.nl>

* Fixed a bug where requirements where not reported when defined in WebTestScenario tests

* Removed an unnecessary test

* [ci skip] prepare release 3.1.17

* [ci skip] prepare for next development iteration

* [ci skip] prepare release 3.1.18

* [ci skip] prepare for next development iteration

* Updated to Selenium 4.1.2

* [ci skip] prepare release 3.1.20

* [ci skip] prepare for next development iteration

* Removed the @deprecated annotation from some of the WebElementFacade methods.

* Updated the Page Elements classes

* Fixed library security issues due to colors.js and xstream 1.4.18

* Bump xstream from 1.4.18 to 1.4.19 (#2683)

Bumps [xstream](https://github.com/x-stream/xstream) from 1.4.18 to 1.4.19.
- [Release notes](https://github.com/x-stream/xstream/releases)
- [Commits](https://github.com/x-stream/xstream/commits)

---
updated-dependencies:
- dependency-name: com.thoughtworks.xstream:xstream
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Create SECURITY.md

* 🚑 FIX an error when executing actions on After methods (#2693)

* serenity-junit5: replace org.junit.AssumptionViolatedException with org.opentest4j.TestAbortedException (#2687)

* Update README.md

* Fixed #2695

* Minor refactoring.

* Fixed an issue with capitalisation of test titles containing apostrophes.

* Refactoring.

* Performance enhancements

* Updated some javadocs regarding proxy settings

* Updated proxy documentation in Javadoc

* Refactored to make unit tests less OS-specific

* Refactored to make unit tests less OS-specific

* Switch some tests to Firefox for variety

* Use a standardised path for requirements to make the tests less OS-dependent

* Fixed a potential Windows-specific issue when reading requirements

* fix: BrowserStack session properties not parsed correctly if null (#2701)

Co-authored-by: Keith <xxthePantzxx@gmail.com>

* Fixed Windows-specific issue related to analysing requirements

* Fixed OS-specific unit tests

* Requirements display the parent requirement if duplicate requirement names are present

* Improvements in the requirements reporting

* Fixed #2688

* [ci skip] prepare release 3.2.0

* [ci skip] prepare for next development iteration

* Updated javadocs

* Added release notes for version 3.2.0

* Update README.md

* Updated release notes

* Added Javadoc for shadow dom locators

* Update README.md

* Create codeql-analysis.yml

* Delete codeql-analysis.yml

* improve parallel support for JUnit5 tests

* fix Junit Test

Co-authored-by: John Ferguson Smart <john.smart@wakaleo.com>
Co-authored-by: Serghei Pogodin <pogodin.serg@gmail.com>
Co-authored-by: Serghei Pogodin <serghei.pogodin@rabobank.nl>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: ricardo larrahondo <ricardolarrahondo2@hotmail.com>
Co-authored-by: zeners <zener@sbg.at>
Co-authored-by: Keith Tremorin <thePantz@users.noreply.github.com>
Co-authored-by: Keith <xxthePantzxx@gmail.com>
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

3 participants