tester
tester

Reputation: 1

[Cucumber][JVM][Maven]Tests dosen't run from command line through maven

I am running tests using java, cucumber with Maven. I am using Eclipse IDE. Also the pom.xml has cucumber dependencies. I am running tests in two ways.

  1. From Eclipse IDE: I run tests as Junit tests and the test results are successful.

2: From command promt: My test failed and below is the result.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

SLF4J: Defaulting to no-operation (NOP) logger implementation

SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further   details.

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building CCIRA_Test_Auto 0.0.1
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact xml-apis:xml-apis:jar:2.0.2 has been relocated to xml-apis:xml-apis:jar:1.0.b2
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ CCIRA_Test_Auto ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\rah\Documents\workspace\CCIRA_Test_Auto\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ CCIRA_Test_Auto ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ CCIRA_Test_Auto ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\rah\Documents\workspace\CCIRA_Test_Auto\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ CCIRA_Test_Auto ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ CCIRA_Test_Auto ---
[INFO] Surefire report directory: C:\Users\rah\Documents\workspace\CCIRA_Test_Auto\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------


Results :


Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 10.051s
    [INFO] Finished at: Mon Dec 05 09:30:10 GMT 2016
    [INFO] Final Memory: 7M/62M
    [INFO] ------------------------------------------------------------------------

Upvotes: 0

Views: 3053

Answers (2)

MikeJRamsey56
MikeJRamsey56

Reputation: 2819

The dependency

org.slf4j.impl.StaticLoggerBinder

is not defined in your pom.xml file. However it is defined on your build path in your Eclipse project. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

I would add a dependency in your pom.xml, perhaps something like this:

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>1.7.21</version>
</dependency>

EDIT

A less good but viable alternative is to utilize the Surefire plugin's additionalClasspathElements element "to add custom resources/JARs to your classpath. This will be treated as an absolute file system path, so you may want use ${basedir} or another property combined with a relative path. Note that additional classpath elements are added to the end of the classpath, so you cannot use these to override project dependencies or resources."

I said less good because it is better to track as dependencies in your pom.xml where if you update one dependency to a later version you can see the other dependencies that also have to be updated. You might overlook jars specified down in the surefire plugin.

Upvotes: 1

A user
A user

Reputation: 1108

Try to run using the below command from command prompt

mvn clean test -Dcucumber.options="src/resources/features --tags @@Personne"

Upvotes: 0

Related Questions