简体   繁体   中英

Initialization Error expected a file cucumber to run a .jar

I have an automation test that I use Cucumber, Junit and I can run with Java Application.

Runner Class:

@RunWith(Cucumber.class)
@CucumberOptions(strict = false, features = "src/main/java/FaixaVS_NaoCadastrado/FaixaVS_NaoCadastrado/FaixaVS_NaoCadastrado.feature", glue = { "StepDefinition" }, format = { "pretty",
"json:C:/Automação Receba Em Casa/Evidências/FVS_NaoCadastrado/Relatório/cucumber.json" }, tags = { "~@ignore" })

public class Runner {
}

Jar Class:

public class Jar {
        public static void main(String[] args) {
            Result result = JUnitCore.runClasses(Runner.class);
            for (Failure failure : result.getFailures()) {
                System.out.println(failure.toString());
            }
        }
}

I can run it inside Eclipse as Java Application, but when I Export it like a Runnable jar and run it I receive the follow massage from CMD:

C:\\Users\\c.guiao.de.oliveira>java -jar C:\\Users\\c.guiao.de.oliveira\\Desktop\\FVS_NaoCadastrado.jar initializationError(FaixaVS_NaoCadastrado.FaixaVS_NaoCadastrado.Runner): Expected a file URL:rsrc:cucumber-java-1.2.3.jar

Can you help me?

Few options:

  • Verify that the path you are using to get resource is correct. I encounter tests that IntelliJ (that is not case sensitive when it comes to resource path) executed successfully and maven clean install failed.

  • Verify that cucumber dependencies are part of the jar. It can work in IntelliJ if you mistakenly added it to the classpath instead of adding it to the pom.xml file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM