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

No Class Def Found io error on running TestNG runner #110

Closed BalurQA closed 5 years ago

BalurQA commented 5 years ago

Hi @prashant-ramcharan , I used courgette-jam in my project and did all necessary in the project. But on running the testng runner class I am getting below error.

Can you please help me to resolve it. Thank you

`Tests run: 5, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 2.469 sec <<< FAILURE! - in TestSuite
initialize(framework.core.RunTestInParallel)  Time elapsed: 1.578 sec  <<< FAILURE!
java.lang.NoClassDefFoundError: io/cucumber/core/options/FeatureOptions
Caused by: java.lang.ClassNotFoundException: io.cucumber.core.options.FeatureOptions

Results :

Failed tests: 
  RunTestInParallel>TestNGCourgette.initialize:25 » NoClassDefFound io/cucumber/...
`

Runner Class

import courgette.api.CourgetteOptions;
import courgette.api.CourgetteRunLevel;
import courgette.api.testng.TestNGCourgette;
import cucumber.api.CucumberOptions;
import cucumber.api.testng.TestNGCucumberRunner;
import framework.core.drivers.Core;
import framework.core.models.Config;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Properties;

@Test
@CourgetteOptions(
        threads = 10,
        runLevel = CourgetteRunLevel.SCENARIO,
        rerunFailedScenarios = false,
        showTestOutput = true,
        reportTargetDir = "test-output",
        cucumberOptions = @CucumberOptions(
                features = "/src/main/resources/features",
                glue = "steps",
                tags = {"@NEW_TEST"},
               plugin = {
                        "pretty",
                        "json:test-output/cucumber-report/cucumber.json",
                        "html:test-output/cucumber-report/cucumber.html"},
                strict = true
        ))
public class RunTestInParallel extends TestNGCourgette {

        private static final Logger logger = LogManager.getLogger(CucumberRunner.class);
        private static Config config;

        @BeforeClass
        public void setup() {
                try {

                        StringWriter writer = new StringWriter();
                        Properties props = System.getProperties();
                        props.list(new PrintWriter(writer));
                        logger.info("System properties set at runtime: {}", writer.toString());

                        Core.initialize();
                        config = Core.getConfig();
                } catch (Exception e) {
                        logger.error("Exception:setup = Failed to set up Cucumber - {}", e.getMessage());
                        e.printStackTrace();
                }
        }

        @AfterClass
        public void teardown() {
                if (!Core.isDriverNull()) {
                        Core.stopWebDriver();
                }
                logger.debug("Writing reports");
        }

}

Required Dependency fieles in pom.xml

image

image

prashant-ramcharan commented 5 years ago

Remove all references to io.cucumber:cucumber-xxx:3.0.2 from your pom.xml

Just keep the Courgette dependency in your pom.xml.

BalurQA commented 5 years ago

@prashant-ramcharan : I tried removing io.cucumber references. Now I am getting another error after removing it.

java.io.IOException: Cannot run program "java": CreateProcess error=206, The filename or extension is too long
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at courgette.runtime.CourgetteFeatureRunner.run(CourgetteFeatureRunner.java:27)
    at courgette.runtime.CourgetteRunner.runFeature(CourgetteRunner.java:153)
    at courgette.runtime.CourgetteRunner.lambda$run$1(CourgetteRunner.java:49)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
prashant-ramcharan commented 5 years ago

This is a Windows limitation.. see https://github.com/prashant-ramcharan/courgette-jvm#limitations-and-known-issues

Upgrading to Java 9 upwards resolves this issue.

BalurQA commented 5 years ago

Okay.. let me try by upgrading to JAVA 9