prashant-ramcharan / courgette-jvm

Multiprocess | Parallel Cucumber-JVM | Parallelize your Java Cucumber tests on a feature level or on a scenario level.
MIT License
133 stars 39 forks source link

Unable to run the tests in Jenkins #194

Closed harsharg closed 4 years ago

harsharg commented 4 years ago

The tests run fine locally, but when running in Jenkins, the tests are getting failed.It's a multi module maven project , getting below error and the tests are not executed.Please advice.

Error:

INFO] Running null [ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.032 s <<< FAILURE! - in null [ERROR] Time elapsed: 0.002 s <<< ERROR! courgette.runtime.CourgetteTestFailureException: Please refer to Courgette / Cucumber report for more info.

Runner file: @RunWith(Courgette.class) @CourgetteOptions( threads = 1, runLevel = CourgetteRunLevel.SCENARIO, rerunFailedScenarios = false, rerunAttempts = 1, showTestOutput = true, reportTargetDir = "build", cucumberOptions = @CucumberOptions( tags = {"@smokeTest"}, features = {"src/test/resources/features"}, glue = {"steps"}, monochrome = true, dryRun = false, plugin = {"pretty", "json:build/cucumber-report/cucumber.json", "html:build/cucumber-report/cucumber.html", "junit:build/cucumber-report/cucumber.xml"}))

POM:

jcenter https://jcenter.bintray.com/
<dependencies>
    <!-- selenium dependency -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>

    <!--cucumber wrapper -->
    <dependency>
        <groupId>io.github.prashant-ramcharan</groupId>
        <artifactId>courgette-jvm</artifactId>
        <version>4.6.2</version>
    </dependency>
org.apache.maven.plugins maven-surefire-plugin 2.22.0 **/runners/SeleniumTest.class org.apache.maven.surefire surefire-junit47 2.22.0
harsharg commented 4 years ago

Hi Prasanth, Please let me know if you need additional info, adding the folder structure

image

harsharg commented 4 years ago

@prashant-ramcharan

Tried multiple ways, still seeing same issue, the test starts but fails to execute in Jenkins.Please help.

Runner: image

Jenkins console:

image

prashant-ramcharan commented 4 years ago

Hello,

It looks like the Courgette runner is being pick up.

Can you provide the cucumber.json ?

Can you also confirm that your tests run fine without Courgette in Jenkins?

harsharg commented 4 years ago

I noticed that the cucumber.json is pointing to the execution on 13th June, it's not showing the latest execution

prashant-ramcharan commented 4 years ago

The issue seems to be with your tests + chrome browser + Jenkins setup.

Looking at the cucumber.json you provided, there is a org.openqa.selenium.WebDriverException causing the error.

This error is not related to Courgette so please first make sure that you can run your tests successfully in Jenkins without Courgette.

harsharg commented 4 years ago

Sure, will do, wanted to check if using this dependency will cause any issues

net.masterthought cucumber-reporting 4.10.0
prashant-ramcharan commented 4 years ago

The issue is not with Courgette because your tests does execute.

In your Jenkins build a CourgetteTestFailureException is raised which means Courgette successfully executed the tests but there was failures / errors with your Cucumber tests. You will have to resolve those failures / errors first.

Hope this helps.

harsharg commented 4 years ago

I tried to run the tests without courgette and was able to execute them in Jenkins.Please advice.

Runner: @RunWith(Cucumber.class) @CucumberOptions (features="src/test/resources/features", tags = "@smokeTest", glue = "steps",//For instance, once cucumber runs I want to add //plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"} monochrome = true, dryRun = false, strict=false, plugin= {"pretty","json:target/cucumber-report/cucumber.json","html:target/cucumber-htmlreport","junit:target/cucumber-report/cucumber.xml"} )

prashant-ramcharan commented 4 years ago

Unfortunately, I cannot advise any further because the error in your Jenkins build is not related to a Courgette error.

courgette.runtime.CourgetteTestFailureException: Please refer to Courgette / Cucumber report for more info

This means that Courgette ran your tests but there were failures in your tests. This Courgette exception is not the cause of your issue.

Does your tests run fine locally with Courgette?

harsharg commented 4 years ago

Yes, it works fine locally. The error in jenkins occurs when executing before hooks.

image

prashant-ramcharan commented 4 years ago

As it's a Cucumber exception that's being thrown it might be an issue with dependencies / classes in your Jenkins agent / workspace.

Perhaps you can try the following:

  1. Try cleaning up your Jenkins workspace.
  2. Try purging the .m2 repository on you Jenkins agent by running the following maven command mvn dependency:purge-local-repository