Report is not getting generated When i am using cucumber-maven reporting plugin see image here
Primary Thing: Message "net.masterthought.cucumber.ValidationException: No report file was added!" generally comes when there is something wrong in the configuration of Maven Cucumber Html Report Plugin. (configuration example below)
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>4.2.3</version>
<executions>
<execution>
<id>execution</id>
<phase>verify</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>TheDayAfterTomorrow</projectName>
<!-- output directory for the generated report -->
<outputDirectory>${project.build.directory}/cucumber-maven-report</outputDirectory>
<inputDirectory>${project.build.directory}/cucumber-json</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/*.json</param>
</jsonFiles>
<skippedFails>true</skippedFails>
<enableFlashCharts>true</enableFlashCharts>
<buildNumber>10.2.1</buildNumber>
<parallelTesting>false</parallelTesting>
</configuration>
</execution>
</executions>
</plugin>
Secondary Thing, in case you are still using old version of cucumber (1.2.5) so update your POM file with latest available cucumber version or anything above >=4.0.0 in order to have better outcome.
Cucumber Execution via JUnit:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.6</version>
</dependency>
Cucumber Execution via TestNG:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.6</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>4.2.6</version>
</dependency>
The root cause of this issue is that maven-cucumber-reporting can't find any JSON file in the directory that was defined in the POM. This JSON file is generated using #CucumberOptions annotation in the runner class. So the problem that you see is because you have defined a different directory in #CucumberOptions and in the inputDirectory field within the configuration of the plugin in the POM file.
To solve it, make sure that both directories match. For example:
In the runner file you should have target/cucumber/cucumber.json
#CucumberOptions(features = "classpath:feature", tags = "#component-test",
glue = {"feature.component"},
plugin = {"json:target/cucumber/cucumber.json")
So in the POM you should have <inputDirectory>${project.build.directory}/cucumber</inputDirectory> and you should make sure that jsonFiles property is correctly defined:
<jsonFiles>
<param>**/*.json</param>
</jsonFiles>
So at the end the configuration should look like:
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>${maven-cucumber-reporting.version}</version>
<executions>
<execution>
<id>generate-cucumber-reports</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<jsonFiles>
<param>**/*.json</param>
</jsonFiles>
<outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
<inputDirectory>${project.build.directory}/cucumber</inputDirectory>
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
Related
I'm getting this error only when running from the fatjar, mvn run:java works as expected.
SEVERE: MessageBodyWriter not found for media type=application/json, type=class com.example.Greeting, genericType=class com.example.Greeting.
I'm using moxy for json handling. I tried jackson, made no difference. Tried grizzly instead o jetty, same issue.
Here are my pom dependencies:
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
Shade plugin config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<!--<minimizeJar>true</minimizeJar>-->
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.example.http.JettyHttpServer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Jersey version is 2.30.1.
Thanks!
EDIT
Contents of org.glassfish.jersey.internal.spi.AutoDiscoverable does not include org.glassfish.jersey.moxy.json.internal.MoxyJsonAutoDiscoverable
org.glassfish.jersey.logging.LoggingFeatureAutoDiscoverable
org.glassfish.jersey.internal.config.ExternalPropertiesAutoDiscoverable
According to this it should. How do I fix it?
Try loading the dependencies you need explicitly on code and not relying on auto discovery, registering them on Jersey.
The fat jar plug-in tries to analyze your code and see what's being used and what's not, so it can exclude references not used and make a smaller jar. The problem with auto discovery is that since there are no explicit references to some classes, the shade plug-in can just think their aren't being used so they can be removed.
I think there's a way to force them to be included on the plug-in configuration, but I don't remember that configuration from memory, you would have to search for it in the docs.
I have a problem when running EMMA code coverage tool with JMockit + JUnit in maven.
I have a project and I am using JMockit as a mocking framework in it.
Once I run mvn test it is running successfully without any problem. That’s means JMockit is initializing with JUnit in a proper way.
Following is the way how I define my dependency for JMockit and JUnit within my POM (in the exact order).
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
But When I check the project for code coverage with EMMA, it says
java.lang.IllegalStateException: JMockit wasn't properly initialized; check that jmockit.jar precedes junit.jar in the classpath (if using JUnit; if not, check the documentation)
but I think I have configured EMMA plugin correctly and it is given below,
<build>
<defaultGoal>install</defaultGoal>
<plugins>
<!—Some other plugins here -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-alpha-3</version>
<inherited>true</inherited>
<configuration>
<check>
<classRate>100</classRate>
<methodRate>100</methodRate>
<blockRate>70</blockRate>
<haltOnFailure>false</haltOnFailure>
</check>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.googlecode.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>runtime</scope>
<version>${junit.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Can anyone catch what is wrong there ?
I was able to figured out what went wrong there. It seems that we need to specifically say JUnit to use JMockit when work with EMMA.
We can do it by using maven-surefire-plugin.
We need to add following configuration to the POM.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>-javaagent:${settings.localRepository}/com/googlecode/jmockit/jmockit/1.7/jmockit-1.7.jar</argLine>
<useSystemClassLoader>true</useSystemClassLoader>
</configuration>
</plugin>
Note: Make sure to change the location of JMockit Jar in above configuration.
Further, we do not need to have dependencies within EMMA plugin configuration. Just having them in a dependencies section in POM (in exact order) will be enough.
References:
JMockit - initialization problem
I've created a new project which will only run the integration test with
maven-ear-plugin
maven-failsafe-plugin
maven-embedded-glassfish-plugin
When I set the packaging to ear the ear file gets created, glassfish runs but the tests are being ignored and I get the following message
[failsafe:integration-test] No tests to run.
and glassfish undeploy fails
[embedded-glassfish:undeploy]
17/08/2012 10:08:17 AM PluginUtil doUndeploy
INFO: Deployer = com.sun.enterprise.admin.cli.embeddable.DeployerImpl#105f0f87
17/08/2012 10:08:17 AM com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream report
WARNING: Input stream has been finalized or forced closed without being explicitly closed; stream instantiation reported in following stack trace
java.lang.Throwable
at com.sun.enterprise.loader.ASURLClassLoader$SentinelInputStream.(ASURLClassLoader.java:1230)
When I set the packing to jar
I get
Running packageName.MyServiceTest
17/08/2012 10:09:34 AM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient
INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
org.omg.CORBA.COMM_FAILURE: FINE: IOP00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700 vmcid: OMG minor code: 1 completed: No
at sun.reflect.GeneratedConstructorAccessor27.newInstance(Unknown Source)
and glassfish does not start
I know it has to do something with Maven lifecycle that its not allowing me to create the ear file, start the glassfish embedded server and run integration tests in the same project.
Can someone please suggest me a solution ? I'm trying to create the ear file with just the EJB and Business entities project and deploy it to embedded glassfish server to run the integration test with maven-failsafe-plugin instead of deploying the ear file created by the parent pom.xml which adds UI and other projects into the ear file.
Here is my pom.xml file
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent>
<groupId>company.MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>3.8.1-SNAPSHOT</version>
</parent>
<artifactId>MyProject-integration-test</artifactId>
<packaging>jar</packaging>
<name>MyProject Integration Tests</name>
<properties>
<ear-final-name>MyProject-integration-test-${project.version}</ear-final-name>
</properties>
<dependencies>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion</artifactId>
<version>1.4.2</version>
<scope>test</scope>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion-extensions</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>MyProject-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-words-jdk15</artifactId>
<version>${aspose.libraryVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>hibernate-entitymanager</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
</dependency>
<dependency>
<groupId>hibernate-annotations</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>hibernate-commons-annotations</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>3.4.0.GA</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.1.0.5.0</version>
</dependency>
<dependency>
<groupId>ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org-apache-commons-logging</groupId>
<artifactId>org-apache-commons-logging</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.5</version>
<configuration>
<version>5</version>
<displayName>MyProject</displayName>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<finalName>${ear-final-name}</finalName>
<name>MyProject-integration-test</name>
<modules>
<ejbModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-ejb</artifactId>
<bundleFileName>MyProject-ejb.jar</bundleFileName>
</ejbModule>
<jarModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-business-entities</artifactId>
<bundleFileName>MyProject-business-entities-3.8.1-SNAPSHOT.jar</bundleFileName>
</jarModule>
<jarModule>
<groupId>company.MyProject</groupId>
<artifactId>MyProject-util</artifactId>
<bundleFileName>MyProject-util-3.8.1-SNAPSHOT.jar</bundleFileName>
</jarModule>
</modules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>failsafe-integration-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>failsafe-verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-embedded-glassfish-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<goalPrefix>embedded-glassfish</goalPrefix>
<autoDelete>true</autoDelete>
<app>${basedir}/target/MyProject-integration-test-${project.version}.ear</app>
<port>8080</port>
<configFile>src/test/resources/glassfish/config/domain.xml</configFile>
</configuration>
<executions>
<execution>
<id>start-glassfish</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>glassfish-deploy</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>glassfish-undeploy</id>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
</goals>
</execution>
<execution>
<id>stop-glassfish</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Yep, it working now. Turns out the problem was with my domain.xml file. The default domain.xml comes with the port numbers with prefix 2 which should be removed and in embedded glassfish 3.1 < port> 8080 < /port> does not work if < configFile> is set (ref this doco)
http://embedded-glassfish.java.net/nonav/plugindocs/3.1/stop-mojo.html.
I just had to set IIOP port in domain.xml to 3700 and in my test
Properties props = new Properties();
props.put("org.omg.CORBA.ORBInitialPort", "3700");
Context ctx = new InitialContext(props);
Thanks guys
You can do the packaging and starting the glassfish in a single call.
have you tried:
mvn verify
to do so?
Possibly another solution to specify the IIOP ports of Glassfish (first it is necessary to confirm the server IP and IIOP listener ports):
System.setProperty("org.omg.CORBA.ORBInitialHost", "127.0.0.1");
System.setProperty("org.omg.CORBA.ORBInitialPort", "8037");
Context ctx = new InitialContext();
I am trying to configure the selenium server that is used by the selenese command by the Maven-Selenium plugin from codehaus. I have tried to create multiple executions within the plugin start the server in the pre-integration-test phase, which didn't work. The selenium-server simply went into an infinite loop, listening on a port.
I want to know if there is a way to override/configure the selenium-server that the selenese command uses in the plugin. Please let me know.
Please see the POM snippet below.
....
<properties>
<selenium.version>2.0b3</selenium.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.1</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium</artifactId>
<version>${selenium.version}</version>
<type>pom</type>
<exclusions>
<!-- prevent ant:ant versus org.apache.ant:ant collision -->
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<executions>
<execution>
<id>Run-Script</id>
<phase>integration-test</phase>
<goals>
<goal>selenese</goal>
</goals>
<configuration>
<browser>*firefox</browser>
<suite>src/test/selenium/html/TestSuite.html</suite>
<startURL>http://localhost:4444/</startURL>
<results>${project.build.directory}/results/${browser.type}-${test.type}-results.html</results>
<port>4444</port>
<timeoutInSeconds>${selenium.server.timeout.seconds}</timeoutInSeconds>
<multiWindow>${multiple.windows}</multiWindow>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
....
Thanks,
Juan
Try setting startURL to the url of the application under test instead of pointing to the selenium rc server url. For example, if your selenium test case is clicking a link on google, set startURL to http://www.google.com
Here's a snippet from my pom that's working**
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<configuration>
<browser>*firefox</browser>
<startURL>http://my-site.com</startURL>
<suite>test-suite</suite>
<!-- <logOutput>true</logOutput> -->
<!-- <timeoutInSeconds>30</timeoutInSeconds> -->
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>selenese</goal>
</goals>
</execution>
</executions>
</plugin>
** It works great except that on Mac OS, firefox just stays open and doesn't close?! But, hope that helps.
I am not able to use yui-compressor maven plugin in my web app. When I run maven I get following error
[INFO] Internal error in the plugin manager executing goal 'net.sf.alchim:yuicompressor-maven-plugin:0.7.1:compress': Unable to load the mojo 'net.sf.alchim:
yuicompressor-maven-plugin:0.7.1:compress'
in the plugin 'net.sf.alchim:yuicompressor-maven-plugin'. A required class is missing: org.mozilla.javascript.ErrorReporter
Later I found that rhino js plugin contains this class org.mozilla.javascript.ErrorReporter. So I included this plugin in dependency tag but still I am getting the same error.
Has anyone came across such error.
--> updating main question to add the pom plugin details
<plugin>
<groupId>net.sf.alchim</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>0.7.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jslint</goal>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<failOnWarning>true</failOnWarning>
<nosuffix>true</nosuffix>
<aggregations>
<aggregation>
<!-- remove files after aggregation (default: false) -->
<removeIncluded>false</removeIncluded>
<!-- insert new line after each concatenation (default: false) -->
<insertNewLine>false</insertNewLine>
<output>${project.basedir}/${webcontent.dir}/js/compressedAll.js</output>
<!-- files to include, path relative to output's directory or absolute path-->
<!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
<includes>
<include>**/autocomplete.js</include>
<include>**/calendar.js</include>
<include>**/dialogs.js</include>
<include>**/download.js</include>
<include>**/folding.js</include>
<include>**/jquery-1.4.2.min.js</include>
<include>**/jquery.bgiframe.min.js</include>
<include>**/jquery.loadmask.js</include>
<include>**/jquery.printelement-1.1.js</include>
<include>**/jquery.tablesorter.mod.js</include>
<include>**/jquery.tablesorter.pager.js</include>
<include>**/jquery.validate.js</include>
<include>**/jquery-ui-1.8.custom.min.js</include>
<include>**/languageDropdown.js</include>
<include>**/messages.js</include>
<include>**/print.js</include>
<include>**/tables.js</include>
<include>**/tabs.js</include>
<include>**/uwTooltip.js</include>
</includes>
<!-- files to exclude, path relative to output's directory-->
</aggregation>
</aggregations>
</configuration>
<dependencies>
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
<scope>compile</scope>
<version>1.6R5</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.7</version>
<scope>provided</scope>
</dependency><dependency>
<groupId>net.sf.retrotranslator</groupId>
<artifactId>retrotranslator-runtime</artifactId>
<version>1.2.9</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
Could you try the latest version (1.1)?
The 0.7.1 version doesn't even seem to be on the official repository. Maybe a dependency resolution problem?
See the topic Yui compressor StringIndexOutOfBoundsException on jboss
The only way to use yuicompressor on web app is to manually merge it with rhino dependency. Otherwise, the app to run would require specifying required sequence of jars in classloader loading sequence (youcompressor must go before rhino).
I struggled with the ErrorReporter class missing too. I solved it by building a jar-with-dependencies which I then turned around to use in my web app,
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
Once I did that, everything worked. In my jar I could see that the org.mozilla.javascript.ErrorReporter.class was in there and Maven would then compile for me.