I'm trying to run an automated test from the command line, but when using the "mvn clean test" command, only the "BUILD SUCCESS" log is displayed, but the browser is not started and the test is not executed.
I'm using: - Junit 4
Selenium 3.141.59
Java 8
Eclipse IDE
-Maven 3.6.0
Someone can help me ?
I dont know what is happen.
You can add maven surefire plugin in your pom or failsafe:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
</plugin>
</plugins>
</build>
Then try again running:
mvn clean test
All classses containing Test/Tests should be picked up
LOG:
[INFO] Running DummyTest
Test was executed
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in DummyTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
Related
I am trying to build new item in jenkins (1st time) to run autotest in maven.
I configure the jenkins and press build now.
There is a problem I can't find the answer and ask for help please.
This is the error in the console :
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) # miron ---
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/3.0.0-M5/maven-surefire-common-3.0.0-M5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.979 s
[INFO] Finished at: 2022-02-23T10:29:40+02:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "Regression" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test (default-test) on project miron: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5:test failed: Plugin org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M5 or one of its dependencies could not be resolved: Failed to collect dependencies at org.apache.maven.plugins:maven-surefire-plugin:jar:3.0.0-M5 -> org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M5: Failed to read artifact descriptor for org.apache.maven.surefire:maven-surefire-common:jar:3.0.0-M5: Could not transfer artifact org.apache.maven.surefire:maven-surefire-common:pom:3.0.0-M5 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/surefire/maven-surefire-common/3.0.0-M5/maven-surefire-common-3.0.0-M5.pom: Connect to repo.maven.apache.org:443 [repo.maven.apache.org/199.232.192.215, repo.maven.apache.org/199.232.196.215] failed: Connection timed out: connect -> [Help 1]
I am working from work (company).
My POM :
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
Can someone help me solve it please ?
Assume we have a JUnit5 dynamic test like this:
public class ProbaTest {
#TestFactory
public Iterable<DynamicNode> tests() {
return Collections.singleton(
DynamicTest.dynamicTest("aaa", () -> {
throw new AssertionError("FAIL, as planned");
})
);
}
}
When being ran by Surefire Maven plugin, it fails in the following way:
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # proba-retrolambda ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.proba.ProbaTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.025 s <<< FAILURE! - in com.proba.ProbaTest
[ERROR] tests[1] Time elapsed: 0.007 s <<< FAILURE!
java.lang.AssertionError: FAIL, as planned
at com.proba.ProbaTest.lambda$tests$0(ProbaTest.java:14)
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] ProbaTest.lambda$tests$0:14 FAIL, as planned
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
Notable thing about the output is the dynamic name, given to the test by JUnit5 - "tests[1]". It doesn't use the "aaa" display name, given by the test factory, and as far as I saw, there are reasons for that.
I wonder, however - is there a way of explicitly overriding the naming behavior? Is there any way of how can I provide explicit names for a dynamic JUnit test cases by my own?
One thing I've noticed is that you're using Maven Surefire Plugin version 2.22.2, which is a bit outdated.
As far as I know there is no way of getting the #DisplayName output only by configuration, but since version 3.0.0-M4 there's a way of developing extensions to Maven Surefire, so you can make it deal with the #DisplayName the way you want to for reports and console outputs.
Knowing that, the solution to override the test naming is to develop your own extension or to use an existing one.
I've already followed the above path and developed an extension, so feel free to use it, either as reference to develop a new one or as a possible solution.
Just tried running dynamic tests samples with it:
public class TestTest {
#TestFactory
public Iterable<DynamicNode> tests() {
return Collections.singleton(
DynamicTest.dynamicTest("aaa", () -> {
throw new AssertionError("FAIL, as planned");
})
);
}
Collection<DynamicTest> tests = Arrays.asList(
DynamicTest.dynamicTest("Add test",
() -> assertEquals(2, Math.addExact(1, 1))),
DynamicTest.dynamicTest("Multiply Test",
() -> assertEquals(4, Math.multiplyExact(2, 2))));
#TestFactory
Collection<DynamicTest> dynamicTestsWithCollection() {
return tests;
}
#TestFactory
#DisplayName("Calculating")
Collection<DynamicTest> dynamicTestsWithCollectionWithDisplayName() {
return tests;
}
}
And got the following output:
[INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) # maven-surefire-junit5-tree-reporter ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] ├─ TestTest - 0.046s
[INFO] │ ├─ ✔ Calculating Add test - 0.008s
[INFO] │ ├─ ✔ Calculating Multiply Test - 0.001s
[INFO] │ ├─ ✘ tests() aaa - 0s
[INFO] │ ├─ ✔ dynamicTestsWithCollection() Add test - 0.001s
[INFO] │ └─ ✔ dynamicTestsWithCollection() Multiply Test - 0.001s
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestTest.lambda$tests$0:15 FAIL, as planned
[INFO]
[ERROR] Tests run: 5, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.909 s
[INFO] Finished at: 2022-07-24T14:56:02+02:00
[INFO] ------------------------------------------------------------------------
You can check that the #DisplayName is printed as desired. To try it by yourself, just add this to your pom file:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<configuration>
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporterUnicode">
</statelessTestsetInfoReporter>
</configuration>
</plugin>
#ptrthomas
I am also facing issue of "Exception in thread "main" java.lang.StackOverflowError"
https://github.com/intuit/karate/issues/661
According to you,this has been fixed in version '1.0.0' in develop branch.
I am not able to create the jar from develop branch (As I am following these steps:-https://github.com/intuit/karate/wiki/Developer-Guide)
Please push this fix to master and release the new version or tell me how to create jar.
What I did is:-
git clone https://github.com/intuit/karate.git
cd karate
git checkout develop
mvn clean install -P pre-release
After this I am getting this error:-
10:53:42.068 [main] DEBUG com.intuit.karate.XmlUtilsTest - map: {env:Envelope={_={env:Header=null, env:Body={_={QueryUsageBalanceResponse={_={Balance=null, Result={Success=null, Error={Category=DAT, Code=DAT_USAGE_1003, Description=Invalid Request: Invalid Input criteria: No asset found for license/eoc (630289335971198/855939)., Source=SIEBEL}}}, #={xmlns=http://www.intuit.com/iep/ServiceUsage/IntuitServiceUsageABO/V1}}}, #={xmlns=http://www.intuit.com/iep/ServiceUsage/IntuitServiceUsageABO/V1}}}, #={xmlns:S=http://schemas.xmlsoap.org/soap/envelope/, xmlns:env=http://schemas.xmlsoap.org/soap/envelope/}}}
[INFO] Tests run: 21, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 s - in com.intuit.karate.XmlUtilsTest
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] RunnerTest.testRunningFeatureFromJavaApi:92 expected:<someValue> but was:<null>
[ERROR] RunnerTest.testRunningRelativePathFeatureFromJavaApi:100 expected:<someValue> but was:<null>
[ERROR]
ScriptTest.testFromJsKarateGetForJsonObjectVariableAndCallFeatureAndJs:1359
[ERROR] Errors:
[ERROR] ConfigTest.testSettingVariableViaKarateConfig:21 » Runtime javascript evaluati...
[INFO]
[ERROR] Tests run: 242, Failures: 3, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] karate-parent ...................................... SUCCESS [ 0.342 s]
[INFO] karate-core ........................................ FAILURE [ 11.289 s]
[INFO] karate-apache ...................................... SKIPPED
[INFO] karate-junit4 ...................................... SKIPPED
[INFO] karate-junit5 ...................................... SKIPPED
[INFO] karate-netty ....................................... SKIPPED
[INFO] karate-gatling ..................................... SKIPPED
[INFO] karate-demo ........................................ SKIPPED
[INFO] karate-mock-servlet ................................ SKIPPED
[INFO] karate-jersey ...................................... SKIPPED
[INFO] karate-archetype ................................... SKIPPED
The CI build is green so it would help us if you find the root cause and let us know how to fix it.
For now please do this for step 4.
mvn clean install -P pre-release -DskipTests
I'm following the Getting Started version 0.9. I can run the sample application with the full "java -Duser.lan..." command and the double-click on the foo.jar, but when I try the mvn exec:exec alternative it doesn't work.
Here the error in console:
CI0011766:drombler-test-application claudiorosati$ mvn exec:exec
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building drombler-test-application 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.5.0:exec (default-cli) # drombler-test-application ---
Error: Could not find or load main class Projects.drombler-test.drombler-test-application.target.deployment.standalone.conf.logging.properties
[ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:404)
at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:166)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:764)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:711)
at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:289)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.809 s
[INFO] Finished at: 2017-03-08T11:46:48+01:00
[INFO] Final Memory: 24M/981M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.5.0:exec (default-cli) on project drombler-test-application: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [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/MojoExecutionException
Here the section of the pom file of the test-application module:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<commandlineArgs>${additionalExecArgs} -Duser.language=en -Duser.country=US -Djavafx.verbose=true -Dbinary.css=false -Djava.util.logging.config.file=${project.build.directory}/deployment/standalone/conf/logging.properties -jar ${project.build.directory}/deployment/standalone/bin/foo.jar --userdir ${project.build.directory}/userdir</commandlineArgs>
<executable>java</executable>
<classpathScope>runtime</classpathScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.drombler.fx</groupId>
<artifactId>drombler-fx-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<brandingId>foo</brandingId>
<title>MyApplication ${project.version}</title>
<width>1500</width>
<height>1000</height>
<!--Uncomment the following line and specifcy an unused port to create a single instance application -->
<!--<defaultSingleInstancePort>some unused port</defaultSingleInstancePort>-->
</configuration>
</plugin>
</plugins>
</build>
[DEBUG] Executing command line: [java, -Duser.language=en,
-Duser.country=US, -Djavafx.verbose=true, -Dbinary.css=false, -Djava.util.logging.config.file=/Users/claudiorosati/Projects/NetBeans,
Projects/drombler-test/drombler-test-application/target/deployment/standalone/conf/logging.properties,
-jar, /Users/claudiorosati/Projects/NetBeans, Projects/drombler-test/drombler-test-application/target/deployment/standalone/bin/foo.jar,
--userdir, /Users/claudiorosati/Projects/NetBeans, Projects/drombler-test/drombler-test-application/target/userdir]
Error: Could not find or load main class
Projects.drombler-test.drombler-test-application.target.deployment.standalone.conf.logging.properties [ERROR] Command execution failed.
org.apache.commons.exec.ExecuteException: Process exited with an
error: 1 (Exit value: 1)
It looks like there is an issue with paths which have spaces.
Please try the following:
<commandlineArgs>${additionalExecArgs} -Duser.language=en -Duser.country=US -Djavafx.verbose=true -Dbinary.css=false -Djava.util.logging.config.file="${project.build.directory}/deployment/standalone/conf/logging.properties" -jar "${project.build.directory}/deployment/standalone/bin/foo.jar" --userdir "${project.build.directory}/userdir"</commandlineArgs>
I'm having a little difficulty in getting the surefire report to appear in the generated site. I run mvn clean site:site and the report is missing.
My pom.xml looks like this:-
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>testMaven</groupId>
<artifactId>testMaven</artifactId>
<name>Test Maven Project</name>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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.6</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</reporting>
</project>
When I do mvn test, the test runs fine.
$ mvn clean test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Maven Project
[INFO] task-segment: [clean, test]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory c:\workspace\java\rsa\testMaven\target
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 1 source file to c:\workspace\java\rsa\testMaven\target\classes
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 1 source file to c:\workspace\java\rsa\testMaven\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: c:\workspace\java\rsa\testMaven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running testMaven.main.HelloWorldServiceTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 second
[INFO] Finished at: Fri Dec 10 10:42:20 CST 2010
[INFO] Final Memory: 17M/1016M
[INFO] ------------------------------------------------------------------------
May I know what I'm doing wrong here? Thanks.
You need to use the maven-surefire-report-plugin in the reporting section (instead of the maven-surefire-plugin), e.g.
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</reporting>