This question already has an answer here:
json files and called features not found in jenkins (with Karate Framework)
(1 answer)
Closed 1 year ago.
I am using karate default arche type as mentioned in the karate tutorial and running testing successfully with cucumber reports using Eclipse but when i use the same project in Jenkins i am getting following error.
I am using Java 1.8 and Cucumber-reporting tool, Please help me solving this issue as i suspect this is issue with the project structure
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f D:\CogsdaleWorkspace\karate-archetype\pom.xml clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< com.mycompany:myproject >-----------------------
[INFO] Building myproject 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # myproject ---
[INFO] Deleting D:\CogsdaleWorkspace\karate-archetype\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\CogsdaleWorkspace\karate-archetype\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) # myproject ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:testCompile (default-testCompile) # myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\CogsdaleWorkspace\karate-archetype\target\test-classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,24] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,1] static import only from classes and interfaces
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[11,17] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[34,10] cannot find symbol
symbol: class Test
location: class nexusportalapi.TestParallel
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.046 s
[INFO] Finished at: 2019-12-18T07:25:48-06:00
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:testCompile (default-testCompile) on project myproject: Compilation failure: Compilation failure:
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,24] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[3,1] static import only from classes and interfaces
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[11,17] package org.junit does not exist
[ERROR] /D:/CogsdaleWorkspace/karate-archetype/src/test/java/nexusportalapi/TestParallel.java:[34,10] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class nexusportalapi.TestParallel
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
POM FILE
`http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.mycompany</groupId>
<artifactId>myproject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.9.4</karate.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.1</version>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
This is hard to tell with just this info, can you try 2 things:
upgrade to Karate version 0.9.5.RC5
use the version we have
tested with for the cucumber-reporting lib: 3.8.0 -
https://github.com/intuit/karate/tree/master/karate-demo#example-report
You are in the best position to troubleshoot this - but you can try follow this process if all else fails: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue
Related
I'm new to maven and one simple thing I wanted to do is pull maven repository and use it in my project.
but this has happened.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ToolsQA</groupId>
<artifactId>jutil_table</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>jutil_table</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.chrisgleissner</groupId>
<artifactId>jutil-protobuf</artifactId>
<version>1.1.11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
App.java
package ToolsQA;
/**
* Hello world!
*
*/
import static com.github.chrisgleissner.jutil.table.TablePrinter.DefaultTablePrinter;
import static java.util.Arrays.asList;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
Iterable<String> HEADERS = asList("id", "name", "age");
DefaultTablePrinter.print(HEADERS, null);
}
}
Complete Error message
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< ToolsQA:jutil_table >-------------------------
[INFO] Building jutil_table 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # jutil_table ---
[INFO] Deleting C:\Users\Pawar\Desktop\mvn_tutorial\jutil_table\jutil_table\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # jutil_table ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Pawar\Desktop\mvn_tutorial\jutil_table\jutil_table\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # jutil_table ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\Pawar\Desktop\mvn_tutorial\jutil_table\jutil_table\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,53] package com.github.chrisgleissner.jutil.table does not exist
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,2] static import only from classes and interfaces
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[18,10] cannot find symbol
symbol: variable DefaultTablePrinter
location: class ToolsQA.App
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.037 s
[INFO] Finished at: 2020-05-24T22:49:15+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project jutil_table: Compilation failure: Compilation failure:
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,53] package com.github.chrisgleissner.jutil.table does not exist
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[8,2] static import only from classes and interfaces
[ERROR] /C:/Users/Pawar/Desktop/mvn_tutorial/jutil_table/jutil_table/src/main/java/ToolsQA/App.java:[18,10] cannot find symbol
[ERROR] symbol: variable DefaultTablePrinter
[ERROR] location: class ToolsQA.App
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I read lot of articles and lot of related questions on stackoverflow about this. but still maven is unable to download the repo. and build is failing.
I used mvn compile, mvn package, mvn clean install nothing worked for me.
Please help✌️
As per the documentation, you need to have all three dependencies. That issue you have posted is not directly relevant to maven. That says the compiler cannot find symbols, may be because the class is not there in the classpath. Try with all the dependencies included.
Or in this case, what you really need the dependency for jutil-table only. You can omit the other two. But your maven pom contain jutil-protobuf dependency.
<dependency>
<groupId>com.github.chrisgleissner</groupId>
<artifactId>jutil-protobuf</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>com.github.chrisgleissner</groupId>
<artifactId>jutil-sql-log</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>com.github.chrisgleissner</groupId>
<artifactId>jutil-table</artifactId>
<version>1.1.11</version>
</dependency>
And build the jar including the dependencies using maven assembly plugin
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass> // Main class Ex : com.Test </mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
I have created a maven project and try to run it with Jenkins.
Below is my Jenkins error:-
I am learning how to run a maven project in Jenkins but Jenkins has given me this error(invalid LOC header (bad signature)) do I need to add the dependency for this also.
but I already did that and still, I am facing this issue.
I have commented on some of the plugins.
There are more error in Jenkins, check that too, please
Executing Maven: -B -f /home/oci/git/Maven_First_Project/com.first_maven/pom.xml clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.code_maven:maven_first >---------------------
[INFO] Building com.maven_first 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # maven_first ---
[INFO] Deleting /home/oci/git/Maven_First_Project/com.first_maven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # maven_first ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # maven_first ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/oci/git/Maven_First_Project/com.first_maven/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar; invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29] package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16] cannot find symbol
symbol: variable FileUtils
location: class com.all_data_page.Online_Booking
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.437 s
[INFO] Finished at: 2019-10-23T17:54:38+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven_first: Compilation failure: Compilation failure:
[ERROR] error reading /home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar; invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29] package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16] cannot find symbol
[ERROR] symbol: variable FileUtils
[ERROR] location: class com.all_data_page.Online_Booking
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving /home/oci/git/Maven_First_Project/com.first_maven/pom.xml to com.code_maven/maven_first/0.0.1-SNAPSHOT/maven_first-0.0.1-SNAPSHOT.pom
/home/oci/git/Maven_First_Project/com.first_maven/pom.xml is not inside /home/oci/.jenkins/workspace/Testing_maven/home/oci/git/Maven_First_Project/com.first_maven/; will archive in a separate pass
ERROR: Failed to parse POMs
java.nio.file.NoSuchFileException: /home/oci/.jenkins/workspace/Testing_maven/home/oci/git/Maven_First_Project/com.first_maven/pom.xml
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
at java.base/java.nio.file.Files.newByteChannel(Files.java:370)
at java.base/java.nio.file.Files.newByteChannel(Files.java:421)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:155)
at hudson.FilePath.read(FilePath.java:1942)
at jenkins.plugins.maveninfo.extractor.properties.PomPropertiesFinder.findProperties(PomPropertiesFinder.java:50)
at jenkins.plugins.maveninfo.extractor.MavenInfoExtractor.extract(MavenInfoExtractor.java:58)
at jenkins.plugins.maveninfo.extractor.MavenInfoEnvironment.tearDown(MavenInfoEnvironment.java:42)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:908)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1838)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Finished: FAILURE
This is my Pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.code_maven</groupId>
<artifactId>maven_first</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.maven_first</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test-output/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test-output/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
These are the main errors as below:
[ERROR] error reading
/home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar;
invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29]
package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16]
cannot find symbol
Error 1:
Go the below location
/home/oci/.m2/repository/org/apache-extras/
Delete all folder here, sometimes jar corrupts and need to download again by clean install
Source:
Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature)
Error 2:
Maven package error: org.apache.commons-lang does not exist (Java)
Error 3:
its may be due to incompatibility between jar version, try to find the dependencies which are not compatible
Hi im new in selenium and im trying to build a test using maven. I followed some steps in running/setting up maven via pom.xml file. i tried to updated the Maven project but still the same error is displayed. However, im encountering an error. see details of pom.xml file and the error. Please help im just new in using Selenium Web and just want to learn.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FAM.Automation.Test</groupId>
<artifactId>FAM.Automation.Selenium</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<jre.level>1.8</jre.level>
<jdk.level>1.8</jdk.level>
</properties>
<build>
<plugins>
<!-- Compiler plug-in -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<version>3.6.1</version>
</plugin>
<!-- Below plug-in is used to execute tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<suiteXmlFiles>
<suite name="Suite" parallel="none">
<test name="Test">
<classes>
<class name="Automation.fam.test.GoogleHomePageTitle"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
<!-- TestNG suite XML files -->
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Error when building the test:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building FAM.Automation.Selenium 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # FAM.Automation.Selenium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) # FAM.Automation.Selenium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # FAM.Automation.Selenium ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) # FAM.Automation.Selenium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) # FAM.Automation.Selenium ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.201 s
[INFO] Finished at: 2018-03-09T19:02:34+08:00
[INFO] Final Memory: 11M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project FAM.Automation.Selenium: Unable to parse configuration of mojo org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test for parameter suiteXmlFiles: Basic element 'suite' must not contain child elements -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException
suiteXmlFiles: Basic element 'suite' must not contain child elements
I think you should not use
<suite ...
inside
<suiteXmlFiles>
Use <suiteXmlFiles> to include a file.
Ref:
http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html
I have created a very simple project in Eclipse to run a very simple JUnit test. These tests work fine when tests are executed from within Eclipse, but the code does not compile when run via maven command line.
The command I am using to run maven is simply 'maven test'. The following is the maven output:
MacBook-Pro:leonard-reference-test randy$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building leonard-reference-test 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # leonard-reference-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # leonard-reference-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/randy/PSH/workspaces/playground/leonard-reference-test/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[3,17] package org.junit does not exist
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[8,10] cannot find symbol
symbol: class Test
location: class info.leonard.reference.test.ReferenceTestClient
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.043 s
[INFO] Finished at: 2015-12-15T19:10:49-07:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project leonard-reference-test: Compilation failure: Compilation failure:
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[3,17] package org.junit does not exist
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[8,10] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class info.leonard.reference.test.ReferenceTestClient
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
MacBook-Pro:leonard-reference-test randy$
The pom.xml for this is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>info.leonard.reference</groupId>
<artifactId>leonard-reference-test</artifactId>
<version>0.0.1</version>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
</plugins>
</build>
</project>
And the only Java file in the project is as follows:
package info.leonard.reference.test;
import org.junit.Test;
public class ReferenceTestClient
{
#Test
public void testOne()
{
System.out.println("simple test");
}
}
That's it... no other files in the project. Maven tests run successfully from within Eclipse, but the code doesn't even compile from within Maven.
A valid pom.xml file, or other modifications to this simple project, is appreciated.
You have your file in src/main/java/ directory but the scope for the JUnit dependency is test. This means maven will not take it into account when compiling non-test code. Please put your file in src/test/java.
Test scope means that junit is only available in src/test/java
move
/Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:
over to
/Users/randy/PSH/workspaces/playground/leonard-reference-test/src/test/java/info/leonard/reference/test/ReferenceTestClient.java:
Hi I'm trying to use the maven android plugin and robolectric to get tests working. Right now I just have one test class which is under src/test.... I've followed the instructions here to try and get this working: http://pivotal.github.com/robolectric/maven-quick-start.html
UPDATED: I have followed the advice of those who posted to me here and here is my latest Pom.xml and compile output.
Here is my Pom.xml:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mozilla.android.sync</groupId>
<artifactId>android-sync</artifactId>
<version>1</version>
<packaging>apk</packaging>
<name>sync</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- try 4.10 once we get this working -->
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<!--<pluginManagement>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<!--
<artifactId>maven-android-plugin</artifactId>
<version>2.8.4</version>-->
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-13</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>10</platform>
</sdk>
<emulator>
<!-- the name of the avd device to use for starting the emulator -->
<avd>android-14</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<!--</pluginManagement>-->
</build>
</project>
Output of mvn clean install:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sync 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # android-sync ---
[INFO] Deleting /Users/jason/dev/work/android-sync/target
[INFO]
[INFO] --- android-maven-plugin:3.0.0-alpha-13:generate-sources (default-generate-sources) # android-sync ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /Users/jason/dev/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/jason/dev/work/android-sync/target/generated-sources/r, -M, /Users/jason/dev/work/android-sync/AndroidManifest.xml, -S, /Users/jason/dev/work/android-sync/res, --auto-add-overlay, -I, /Users/jason/dev/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # android-sync ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/src/main/resources
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/target/generated-sources/extracted-dependencies/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # android-sync ---
[INFO] Compiling 21 source files to /Users/jason/dev/work/android-sync/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
symbol: class RunWith
#RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
symbol : class Test
location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
symbol : method equalTo(java.lang.String)
location: class org.mozilla.android.sync.test.MyActivityTest
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.019s
[INFO] Finished at: Sat Nov 12 13:02:42 PST 2011
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project android-sync: Compilation failure: Compilation failure:
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] #RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
[ERROR] symbol : class Test
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
[ERROR] symbol : method equalTo(java.lang.String)
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I think you might have that problem due to the order of the test dependency in the pom file. Move the junit one to be the last one or at least behind the robolectric one. That should fix it.
Check out the working robolectric sample app for more comparison.
I did make sure that all dependencies were listed before the android dependencies
Actually the order of dependencies does matter, in the link your provided yourself, see the important comments in the sample pom.xml:
<!-- Make sure this is below the android dependencies -->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>X.X.X</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
From my own experiences, I think this library is still in a development stage, their API is not stable and change quite a lot between different version, code working in a old version for example 0.9.4 may not working in 1.0-XX or later. try download/use the latest versrion from there sonatype repository
So I was having the same problems too. For what it's worth, I wasn't using maven or gradle, here's how I fixed this issue.
In your Test class:
Make sure the Roboelectric library is first in the list of dependencies (In IntelliJ, click on your project in the Navigation Pane and hit F4).
import org.junit.runner.RunWith; <- The RunWith annotation is actually part of JUnit.
import org.roboelectric.RoboeletricTestRunner;
I hope this helps!