I'm trying to integrate Karma with Maven using the 1.6 plugin but it fails and states that:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-karma-plugin:1.6:start (default) # amm ---
[INFO] Executing Karma Test Suite ...
cmd /C C:\Dev\Workspaces\projectname\subname/src/main/webapp/node_modules/.bin/kar
ma start C:\Dev\Workspaces\projectname\subname\src\main\webapp\karma.conf.js --bro
wsers Chrome, Firefox --single-run --no-auto-watch --colors true
The system cannot find the path specified.
Here are my settings in the maven pom.xml:
<plugin>
<groupId>com.kelveden</groupId>
<artifactId>maven-karma-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
<configuration>
<karmaExecutable>${ammWorkspaceDir}/src/main/webapp/node_modules/.bin/karma</karmaExecutable>
<configFile>${ammWorkspaceDir}/src/main/webapp/karma.conf.js</configFile>
<browsers>Chrome, Firefox</browsers>
<autoWatch>false</autoWatch>
<singleRun>true</singleRun>
<colors>true</colors>
<skipKarma>false</skipKarma>
<skipTests>false</skipTests>
<karmaFailureIgnore>false</karmaFailureIgnore>
<!-- <reporters>dots,junit</reporters> -->
</configuration>
</plugin>
I did a check using the cmd dir to see if the node_modules folder contains the .bin folder but it only contains:
karma
karma-chrome-launcher
karma-firefox-launcher
karm-jasmine
Where is the .bin folder? Note that I can run all the normal tests but I have to navigate to where the karma.conf.js file is to run them and can run the tests using karma start (they all pass).
So why is this failing? Is karma installed in the wrong place? Should node and such be present as a System variable?
Thanks
I figured out the problem. What was causing the build issue was the fact that the karma node_modules was interfering with the build. To get around this I had to remove the node_modules from the webapp folder and move it into the root directory of the project, as well as the karma.conf.js file.
That was the first part - the second part was to install karma globally using this command:
npm install -g karma && npm install -g karma-cli
By doing this you should beable to run karma from anywhere but that wasn't the case for me and I still don't know why (elaborate anyone?). The final part was in the actually maven pom.xml:
<plugin>
<groupId>com.kelveden</groupId>
<artifactId>maven-karma-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
<configuration>
<configFile>karma.conf.js</configFile>
<browsers>Chrome</browsers>
<autoWatch>false</autoWatch>
<singleRun>true</singleRun>
<colors>true</colors>
<skipKarma>false</skipKarma>
<skipTests>false</skipTests>
<karmaFailureIgnore>false</karmaFailureIgnore>
</configuration>
</plugin>
The key point above is that I haven't included the <karmaExecutable> command here because if you include that then it will break - by keeping it out it will turn to the global karma install to run the tests in the Maven build. This worked for me - hope it works for you.
Related
I am creating a batch multiple test suites for a project. I have a regression test and a smoke test. I need to call it from the batch file, so regression I need to run after a release but smoke every day. However when I run
cd %projectLocation%
call mvn clean test -DsuiteXmlFile=smokeTestRunner.xml
in a file it still jumps to the regression test first. Here is my surefire plugin config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<!-- TestNG suite XML files -->
<suiteXmlFile>regressionTestRunner.xml</suiteXmlFile>
<suiteXmlFile>smokeTestRunner.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
How do I make it run only smoke test or regression test separately? Both runner.xml files and pom.xml are in the same directory
Try this in pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>{suite}.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
And then run in terminal:
mvn clean test -Dsuite=smokeTestRunner
or
mvn clean test -Dsuite=regressionTestRunner
I have a project that has :
Java server that is a WAR deployed on Tomcat. It includes all the Java code of my entities, DAO, Service and API.
JS client built with Foundation for Apps. It includes Angular JS, Bower, Gulp and Sass.
I'm trying to organize the build process of this project but I have difficulties to implement it.
As said in this post How to organize full build pipeline with Gulp, Maven and Jenkins, I tried to use the frontend-maven-plugin but without success.
I have the following error :
`
[ERROR]
[ERROR] events.js:141
[ERROR] throw er; // Unhandled 'error' event
[ERROR] ^
[ERROR] Error: client\assets\scss\_settings.scss
[ERROR] Error: File to import not found or unreadable: helpers/functions
[ERROR] Parent style sheet: C:/Dev/Code/Porteo/fr.porteo.parent/fr.porteo.jersey/porteo_fa/client/assets/scss/_settings.scss
[ERROR] on line 32 of client/assets/scss/_settings.scss
[ERROR] >> #import "helpers/functions";
[ERROR] ^`
It would seem there is a problem with the _settings.css file. He don't recognize the tag #import. But where does the problem come from?
It's surely from maven and the frontent-maven-plugin but how to fix it?
Here my pom.xml with plugin dependencies and executions (only npm start is necessary to run the foundation project) :
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<!-- NB! Set <version> to the latest released version of frontend-maven-plugin, like in README.md -->
<version>0.0.29</version>
<configuration>
<workingDirectory>my_foundation_project</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v5.3.0</nodeVersion>
<npmVersion>3.3.12</npmVersion>
</configuration>
</execution>
<execution>
<id>npm start</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>start</arguments>
</configuration>
</execution>
</executions>
</plugin>
So, Have you any solutions or a better way to implement these two applications?
Issue with similar symptoms - caused by bower permissions mismatch
I'm running SonarQube in a jenkins job (using Post-build Actions).
I'm getting the following problem with JaCoCo -
[INFO] [16:57:43.157] Sensor JaCoCoSensor...
[INFO] [16:57:43.157] Project coverage is set to 0% as no JaCoCo execution data has been dumped: /var/lib/jenkins/.../target/jacoco.exec
[INFO] [16:57:43.426] Sensor JaCoCoSensor done: 269 ms
As a result, I'm getting 0% code coverage for my project.
Couldn't find why jacoco.exec is not being created.
I don't have "JaCoCo" configured to run by maven (in my pom.xml).
I know that in the past the jacoco.exec was created anyway (probably by Sonar itself).
What am I doing wrong? Do I need to configure JaCoCo in my pom.xml for it to work?
Thanks.
From the web Java Ecosystem:
It is no longer possible to let SonarQube drive the execution of the
unit tests. You now have to generate the JUnit and code coverage
(JaCoCo or Cobertura or Clover) reports prior to the SonarQube
analysis and then feed SonarQube with those reports.
So you need to include Jacoco in the pom.xml:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.0.201403182114</version>
<configuration>
<destFile>${basedir}/target/jacoco-unit.exec</destFile>
<dataFile>${basedir}/target/jacoco-unit.exec</dataFile>
</configuration>
<executions>
...
</executions>
</plugin>
And give this data file to SonarQube:
sonar.jacoco.reportPath=target/jacoco-unit.exec
According to this blog you can enable the creation of jacoco.exec files by adding the following plugin section to your pom.xml (it worked for me):
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.1.201405082137</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
I would like to check if there is any plugin that exists for running mocha test cases in maven test phase, and to return BUILD SUCCESS or FAILURE based on test result
-lucky
I was interested in the question too. I'm testing the nodejs code, so it may be not very relevant.
No success so far discovering the plugin I need, but if you need only the failing build process you can use maven-antrun-plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>test-nodejs</id>
<phase>test</phase>
<configuration>
<tasks name="Run mocha tests">
<exec dir="${basedir}"
executable="npm"
failonerror="true">
<arg value="test"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Pay attention to failonerror argument.
One more thing to note (in case of NodeJS) - you need to setup the package.json file to support npm test command, e.g.
"scripts": {
"test" : "mocha -R tap"
},
and your tests should reside in test folder. Also, mocha treats subfolder well enough, so you can make reasonable test case folder structure.
I'm trying to build my application for GoogleAppEngine using maven. I've added the following to my pom which should "enhance" my classes after building, as suggested on the DataNucleus documentation
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.4</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
According to the documentation on GoogleAppEngine, you have the choice to use JDO or JPA, I've chosen to use JPA since I have used it in the past. When I try to build my project (before I upload to GAE) using mvn clean package I get the following output
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.
Missing:
----------
1) javax.jdo:jdo2-api:jar:2.3-ec
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=javax.jdo -DartifactId=jdo2-api -Dversion=2.3-ec -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=javax.jdo -DartifactId=jdo2-api -Dversion=2.3-ec -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
Path to dependency:
1) org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4
2) javax.jdo:jdo2-api:jar:2.3-ec
----------
1 required artifact is missing.
for artifact:
org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4
from the specified remote repositories:
__jpp_repo__ (file:///usr/share/maven2/repository),
DN_M2_Repo (http://www.datanucleus.org/downloads/maven2/),
central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3 seconds
[INFO] Finished at: Sat Apr 03 16:02:39 BST 2010
[INFO] Final Memory: 31M/258M
[INFO] ------------------------------------------------------------------------
Any ideas why I should get such an error? I've searched through my entire source code and I'm not referencing JDO anywhere, so unless the app engine libraries require it, I'm not sure why I get this message.
The DataNucleus Maven plugin requires the JDO2 API JAR (even for JPA) as documented here and as reported in the trace:
Path to dependency:
1) org.datanucleus:maven-datanucleus-plugin:maven-plugin:1.1.4
2) javax.jdo:jdo2-api:jar:2.3-ec
The odd part is that jdo2-api-2.3-ec.jar is in the DataNucleus Maven repository (that is declared in the POM of the plugin) and Maven has checked this repository as we can see in the trace.
Update: Ok, this is definitely weird and I don't know why the build is failing exactly (maybe a problem with dependencies ranges). As a workaround, declare the JDO2 API JAR as dependency in the plugin:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.4</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-ec</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
...
</plugins>
...
</build>
</project>
With this dependency declared, the JAR gets downloaded.