When i start mvn clean test site and test failure, allure need attach screenshot and body,but on the Java 11 body and attachements not creating.
That is also for Steps.Probably it depends on Java version and aspectJ library.
On the Java 8 it's working
No exceptions is shown.
Maybe some ideas how to configure with Java 11
Here pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>11</compiler.version>
<maven.surefire.version>2.22.0</maven.surefire.version>
<maven.compiler.version>3.8.0</maven.compiler.version>
<appium.version>7.0.0</appium.version>
<selenium.version>3.141.59</selenium.version>
<allure.testng.version>2.8.1</allure.testng.version>
<allure.maven.plugin.version>2.9</allure.maven.plugin.version>
<allure.report.version>2.7.0</allure.report.version>
<aspectj.version>1.9.1</aspectj.version>
<jetty.maven.plugin.version>9.4.12.RC2</jetty.maven.plugin.version>
<exclude.tag></exclude.tag>
</properties>
<dependencies>
<dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>${allure.testng.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>
src/test/resources/testng.xml
</suiteXmlFile>
</suiteXmlFiles>
<testFailureIgnore>true</testFailureIgnore>
<argLine>
--illegal-access=permit
</argLine>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
<excludedGroups>${exclude.tag}</excludedGroups>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.plugin.version}</version>
<configuration>
<webAppSourceDirectory>
${project.build.directory}\site\allure-maven-plugin
</webAppSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<excludeDefaults>true</excludeDefaults>
<plugins>
<plugin>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-maven</artifactId>
<version>${allure.maven.plugin.version}</version>
</plugin>
</plugins>
</reporting>
The problem is that AspectJ supports Java 11 since version 1.9.2. You are using 1.9.1.
Related
I have structure:
- test
- java
- com
- A
- service
- serviceB
- DefaultServiceBTest.java
- integration
- DefaultServiceBIntegrationTest.java
I want to run separately unit and integration tests. I am using maven surefire and failsafe plugins:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<printSummary>true</printSummary>
<excludes>
<exclude>integration/*.java</exclude>
</excludes>
</configuration>
</plugin>
Since mvn test defaultly runs surefire:test having this configuration for maven-surefire works, and using mvn test only runs unit tests - in my case all tests that are not in integration folder.
However for failsafe i have this configuration:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.plugin.version}</version>
<configuration>
<includes>
<include>**/integration/*.java</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
Having this configuration for maven-failsafe and running mvn verify -Pfailsafe results in first running unit tests, and then integration tests. However i dont want the unit tests to be executed with this. What is wrong with the configuration?
Thanks for help!
First you should not separate your unit tests from integration tests by using different directories. Use the existing naming conventions. Unit Test *Test.java and integration tests *IT.java...
Use the following configuration in your POM 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.soebes.youtube.maven.episodes</groupId>
<artifactId>example-episode-2</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Episode 2: Unit- and/or Integration Testing</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.23.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<skipTests>${skipUTs}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M8</version>
<configuration>
<skipTests>${skipITs}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
By using that you can run your unit tests via:
mvn test
You can run your unit- and your integration tests via:
mvn verify
If you like to run your integration tests only:
mvn verify -DskipUTs
For detail explanations you could check the following YT video.
Error:
I am trying to upgrade jdk from 1.8 to 11. But it is giving me an error.
Test cases are getting failed.
<profiles>
<profile>
<id>surefire</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>TestNG.xml</suiteXmlFile>
</suiteXmlFiles>
<argLine>
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
-Xmx1024m</argLine>
<forkCount>1</forkCount>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Manager:
<pluginManagement>
<plugins>
<!-- not required this plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>false</skipTests>
<argLine>
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
</argLine>
<excludes>
<exclude>**/*RegressionTest.java</exclude>
</excludes>
<forkCount>1</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.3.0.603</version>
</plugin>
</plugins>
</pluginManagement>
I have tried with changing the surefire version. So issue get changed. But I am not able to get the solution for the above error.
I'm new to Maven (first university assignment), and I'm trying to find help wherever I can.
I'm supposed to configure Maven in order for it to compile, create a JAR file, and generate javadoc when using the mvn package command.
I've tried adding javadoc goals to the pom.xml file, but nothing seems to force javadoc generation when using the package target.
Do any of you know if it is at all possible to do this ? If so, how ?
EDIT : I tried the below solution, and after reading more documentation, I think what I'm trying to do is to bind the mvn javadoc:javadoc execution to the package phase.
(I'm happy to delete the question if documentation on this exact issue is elsewhere, I have'nt found any though)
pom.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<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>coo</groupId>
<artifactId>TP0</artifactId>
<version>1.1</version>
<name>TP0</name>
<!-- FIXME change it to the project's website -->
<url>https://www.boredbutton.com/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<reportOutputDirectory>${project.build.directory}/docs</reportOutputDirectory>
<destDir>docs</destDir>
<nohelp>true</nohelp>
<!-- <additionalOptions>-html5</additionalOptions> -->
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>student.MainStudent</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
You have to configure a goal and a phase:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<goals>
<goal>javadoc</goal>
</goals>
<id>execution1</id>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
I am trying to import the java selenium libraries however, I am receiving this issue:
[Java] package org.openqa.selenium.chrome does not exist
And in 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>javafx</groupId>
<artifactId>javafx</artifactId>
<version>javafx</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<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>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.10</version>
</dependency>
<dependency>
<groupId>com.github.ngeor</groupId>
<artifactId>checkstyle-rules</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<configuration>
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>
<!--
You can run jacoco in the default profile with:
mvn jacoco:prepare-agent test jacoco:report
-->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<configuration>
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
<profiles>
<!--
This profile enables jacoco when unit tests are run.
You can run it with mvn -P jacoco test.
It also activates itself on Travis.
-->
<profile>
<id>jacoco</id>
<activation>
<property>
<name>env.TRAVIS</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>prepare-agent</id>
<phase>validate</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!--
For the Travis profile:
- we want to break the build on any checkstyle violation.
- we want to be able to publish coverage report to coveralls.
-->
<profile>
<id>travis</id>
<activation>
<property>
<name>env.TRAVIS</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>checkstyle</id>
<phase>test</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I am using Visual Studio code and I keep updating the pom.xml file. However, I am still unable to make my java file recognize selenium. I extracted the dependency code directly from the website and put it under the <dependencies> tag.
You POM is correct . I am able to import dependencies from eclipse using shared pom.
just clean the repository [delete files related to the things downloaded by maven] and try again mvn clean install. Try to use some IDE which can clearly explain the issues in setting up... [Note : Also check whether setting.xml of maven is correctly linked with Visual Code]
I am trying to use Sigar in my Java Maven application, i added the following dependencies:
<dependency>
<groupId>org.fusesource</groupId>
<artifactId>sigar</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.4.0</version>
</dependency>
but it was throwing thr following exception:
org.hyperic.sigar.SigarException: no libsigar-amd64-linux.so in java.library.path
at org.hyperic.sigar.Sigar.loadLibrary(Sigar.java:172)
at org.hyperic.sigar.Sigar.<clinit>(Sigar.java:100)
at com.ro.terminal.model.utils.TerminalUtils.<clinit>(TerminalUtils.java:28)
at com.ro.terminal.model.service.SyncModule.init(SyncModule.java:187)
at com.ro.terminal.main.Terminalinitializer.<init>(Terminalinitializer.java:124)
at com.ro.terminal.main.Terminalinitializer$3.call(Terminalinitializer.java:339)
at com.ro.terminal.main.Terminalinitializer$3.call(Terminalinitializer.java:1)
at javafx.concurrent.Task$TaskCallable.call(Task.java:1423)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
after googling i knew that i have to add the needed .ddl and .so files in the application and add the path to java.library.path,
i downloaded the files from here and added them under resources/sigar-lib and tried adding the following to my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<systemPropertyVariables>
<org.hyperic.sigar.path>${sigar.libs}</org.hyperic.sigar.path>
</systemPropertyVariables>
<parallel>classes</parallel>
</configuration>
</plugin>
___________________________
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<java.library.path>${sigar.libs}</java.library.path>
</systemPropertyVariables>
</configuration>
</plugin>
______________________
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Djava.library.path=${sigar.libs}:${java.library.path}</argLine>
</configuration>
</plugin>
the ${sigar.libs} is defined as follows:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sigar.libs>${basedir}/src/main/resources/sigar-lib</sigar.libs>
<build.timestamp>${maven.build.timestamp}</build.timestamp>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>
what am i doing wrong? i am running eclipse oxygen on Ubuntu 17.10
project screenshot: