I was trying to rerun the failed scenarios in cucumber, for this I had designed two runner files, one is the actual runner file which has path of feature files along with rerun plugin which specifies path of rerun.txt file and the other runner file which has path of rerun file as feature to be run, So after running both the runner files for the failed scenarios I am getting this error :-
WARNING: No features found at file:/Users/keshavmac/IdeaProjects/com.CucumberHybrid/target/Reports/rerun.txt
Please help me to resolve this error and automatically run the failed scenarios of rerun.txt file.
The actual runner class file is as below:-
package com.framework.runners;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.Test;
#CucumberOptions(features = "src/test/java/com/framework/features",glue = {"com/framework/utils" ,"com/framework/stepDef"},
tags = "#run",
plugin = {
"pretty","json:target/Reports/JsonReport/report.json","junit:target/Reports/Junitreports/report.xml","html:target/Reports/HTMLReport",
"rerun:target/Reports/rerun.txt"
},monochrome=true)
#Test
public class TestRunner extends AbstractTestNGCucumberTests {
}
The rerunner class file is as below:-
package com.framework.runners;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.Test;
#CucumberOptions(features = "target/Reports/rerun.txt",glue = {"com/framework/utils" ,"com/framework/stepDef"},
plugin = {
"pretty","json:target/FailedReports/JsonReport/report.json","junit:target/FailedReports/Junitreports/report.xml",
"html:target/FailedReports/HTMLReport"},
monochrome=true)
#Test
public class ReRunTestRunner extends AbstractTestNGCucumberTests {
}
The pom.xml configuration is :-
<?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>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>org.example</groupId>
<artifactId>com.CucumberHybrid</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>6.1.2</version>
</dependency>
<dependency>
<groupId>com.github.mkolisnyk</groupId>
<artifactId>cucumber-runner</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.16.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>Cucumber Framework Execution Report</projectName>
<outputDirectory>${project.build.directory}/Reports/cucumber-reports</outputDirectory>
<cucumberOutput>${project.build.directory}/Reports/JsonReport/report.json</cucumberOutput>
<buildNumber>42</buildNumber>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<id>testngtest</id>
<phase>test</phase>
</execution>
</executions>
<configuration>
<!-- <systemPropertyVariables> <IsGridSetup>${is.grid}</IsGridSetup>
<HubUrl>${hub.url}</HubUrl> <FeatureName>${feature.name}</FeatureName> <TagName>${tag.name}</TagName>
<BrowserType>${browser.type}</BrowserType> </systemPropertyVariables> -->
<forkCount>3</forkCount> <!-- how many parallel vm get created and execute -->
<reuseForks>false</reuseForks><!-- Every it will create a new vm for
the execution and will not use any existing -->
<testFailureIgnore>true</testFailureIgnore><!-- The execution will continue
even if there is a test failure -->
<includes> <!-- Specify the file name -->
<include>**/*TestRunner.java</include><!-- This will include all the file
which has "Runner" as suffix in their name -->
</includes>
<suiteXmlFiles>
<!-- <suiteXmlFile>${testngxml.location}/testng.xml</suiteXmlFile> -->
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
The console logs are as below:-
[INFO]
[INFO] -------------------< org.example:com.CucumberHybrid >-------------------
[INFO] Building com.CucumberHybrid 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # com.CucumberHybrid ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # com.CucumberHybrid ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # com.CucumberHybrid ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/keshavmac/IdeaProjects/com.CucumberHybrid/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # com.CucumberHybrid ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 15 source files to /Users/keshavmac/IdeaProjects/com.CucumberHybrid/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M5:test (default-test) # com.CucumberHybrid ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.framework.runners.TestRunner
[INFO] Running com.framework.runners.ReRunTestRunner
Aug 10, 2020 4:37:17 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/Users/keshavmac/IdeaProjects/com.CucumberHybrid/target/Reports/rerun.txt
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.851 s - in com.framework.runners.ReRunTestRunner
#run
Scenario: To test search functionality with blank submit # src/test/java/com/framework/features/Home.feature:7
[INFO ] 2020-08-10 16:37:18.331 [main] BaseSetup - New Webdriver instance invoked
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147#{#310}) on port 8150
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Aug 10, 2020 4:37:20 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
[INFO ] 2020-08-10 16:37:20.357 [main] BaseSetup - Chrome browser instance launched successfully
When user opens browser and navigates to test url # com.framework.stepDef.Common_stepDef.user_opens_browser_and_navigates_to_test_url()
The page title verified is My Store
[DEBUG] 2020-08-10 16:37:28.123 [main] HomePage_PF - Banner on homepage of website has been validated.
Given user should be on home page # com.framework.stepDef.Home_stepDef.user_should_be_on_home_page()
[DEBUG] 2020-08-10 16:37:28.159 [main] HomePage_PF - Search field on homepage has been validated.
And search textfield should be visible # com.framework.stepDef.Home_stepDef.search_textfield_should_be_visible()
[DEBUG] 2020-08-10 16:37:30.526 [main] HomePage_PF - Search icon has been clicked.
When user clicks on search button # com.framework.stepDef.Home_stepDef.user_clicks_on_search_button()
java.lang.AssertionError: expected [true] but found [false]
at org.testng.Assert.fail(Assert.java:96)
at org.testng.Assert.failNotEquals(Assert.java:776)
at org.testng.Assert.assertTrue(Assert.java:44)
at org.testng.Assert.assertTrue(Assert.java:54)
at com.framework.stepDef.Home_stepDef.user_clicks_on_search_button(Home_stepDef.java:32)
at ���.user clicks on search button(file:///Users/keshavmac/IdeaProjects/com.CucumberHybrid/src/test/java/com/framework/features/Home.feature:10)
Then user should be displayed validation message "Please enter a search keyword" # com.framework.stepDef.ProductList_stepDef.user_should_be_displayed_validation_message(java.lang.String)
Scenario To test search functionality with blank submit has been failed
Embedding To test search functionality with blank submit [image/png 365303 bytes]
[INFO ] 2020-08-10 16:37:31.638 [main] HomePage_PF - Webdriver instance has been closed
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 14.975 s <<< FAILURE! - in com.framework.runners.TestRunner
[ERROR] com.framework.runners.TestRunner.runScenario["To test search functionality with blank submit", "Optional[To test the Search feature of application]"](1) Time elapsed: 13.995 s <<< FAILURE!
java.lang.AssertionError: expected [true] but found [false]
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR] TestRunner.runScenario expected [true] but found [false]
[INFO]
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO]
[ERROR] There are test failures.
Please refer to /Users/keshavmac/IdeaProjects/com.CucumberHybrid/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[INFO]
[INFO] --- maven-cucumber-reporting:3.16.0:generate (execution) # com.CucumberHybrid ---
[INFO] About to generate Cucumber report.
[INFO] File '/Users/keshavmac/IdeaProjects/com.CucumberHybrid/target/Reports/JsonReport/report.json' contain 1 features
I think you are just missing annotation # and hence no feature is found. Try this -
features = "#target/Reports/rerun.txt"
After discussion in comment section
Rename ReRunTestRunner to start with any letter after "T" (TestRunner, original feature file), as Cucumber picks up feature file in alphabetical order
Related
I am trying to get my first AspectJ aspect running. Setup looks ok to me, following the documentation I can find. e.g.
developers site: https://github.com/kriegaex/org.aspectj
set up instructions: https://github.com/eclipse/org.aspectj/blob/master/docs/developer/IDE.md
join point examples: https://www.eclipse.org/aspectj/doc/released/progguide/language-joinPoints.html
But no aspect will fire, no matter what options I have tried during all today.
I believe the pointcuts is correctly pointing to my method call because I was getting the error about pointcuts not being used when I changed it. (Thats not happening now - dont know what I did :-())
So is the problem in the setup? The pointcuts? How do you go about de-bugging such a situation? Am I missing something in the docs?
POM
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.14.0</version>
<!--
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.2-SNAPSHOT</version>
-->
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.7</version>
</dependency>
</dependencies>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<forceAjcCompile>true</forceAjcCompile>
<sources/>
<weaveDirectories>
<weaveDirectory>${project.build.directory}/classes</weaveDirectory>
</weaveDirectories>
<complianceLevel>11</complianceLevel>
<source>11</source>
<target>11</target>
<verbose>true</verbose>
<Xlint>warning</Xlint>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
.....
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>22.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/dev.aspectj/aspectj-maven-plugin -->
<dependency>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.7</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.7</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjtools -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.7</version>
</dependency>
</dependencies>
ASPECT
public aspect MdDOMAINChildAspect {
pointcut myExceptionHandlerPointcut(): execution(void mdDOMAIN.MdDOMAINInstance.testCall() );
before(): myExceptionHandlerPointcut() {
System.out.println("-------------- Aspect Advice Logic ---------------");
}
CLASS
#Data
public class MdDOMAINInstance {
#MdDOMAINChildAnnotation(selectName = "Indicators")
public MdDOMAINInstance selectFilingIndicators() throws NoSuchMethodException {
testCall();
Method m=this.getClass().getMethod("selectFilingIndicators");
MdDOMAINChildAnnotation metaidAnnotation=m.getAnnotation(MdDOMAINChildAnnotation.class);
System.out.println("Annotation: " + metaidAnnotation.selectName());
return this;
}
public void testCall()
{
System.out.println("In testCall()");
return ;
}
}
TEST
class MdDOMAINInstanceTest {
#Test
void selectFilingIndicatorsTest() throws NoSuchMethodException {
MdDOMAINInstance mdDOMAINInstance = new MdDOMAINInstance().selectFilingIndicators();
}
}
MAVEN TEST RUN
clean test -Dtest=MdDOMAINInstanceTest -f pom.xml
MAVEN TEST RUN OUTCOME
"C:\Program Files\Java\jdk-11.0.12\bin\java.exe" -Dmaven.multiModuleProjectDirectory=....IdeaProjects\us-MYROOT-DOMAIN-004 "-Dmaven.home=C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3\bin\m2.conf" "-Dmaven.ext.class.path=C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven-event-listener.jar" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\lib\idea_rt.jar=52349:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.6.0.jar;C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\plugins\maven\lib\maven3\boot\plexus-classworlds.license" org.codehaus.classworlds.Launcher -Didea.version=2021.3.2 clean test -Dtest=MdDOMAINInstanceTest
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for us-MYROOT:us-MYROOT-DOMAIN-004:jar:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter:jar is either LATEST or RELEASE (both of them are being deprecated) # line 117, column 22
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 20, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] --------------< us-MYROOT:us-MYROOT-DOMAIN-004 >--------------
[INFO] Building us-MYROOT-DOMAIN-004 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # us-MYROOT-DOMAIN-004 ---
[INFO] Deleting .....IdeaProjects\us-MYROOT-DOMAIN-004\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # us-MYROOT-DOMAIN-004 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # us-MYROOT-DOMAIN-004 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to .....IdeaProjects\us-MYROOT-DOMAIN-004\target\classes
[INFO]
[INFO] --- aspectj-maven-plugin:1.14.0:compile (default) # us-MYROOT-DOMAIN-004 ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # us-MYROOT-DOMAIN-004 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # us-MYROOT-DOMAIN-004 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to .....IdeaProjects\us-MYROOT-DOMAIN-004\target\test-classes
[INFO]
[INFO] --- aspectj-maven-plugin:1.14.0:test-compile (default) # us-MYROOT-DOMAIN-004 ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: OpenJDK javac, ECJ
<unknown source file>:<no line information>
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # us-MYROOT-DOMAIN-004 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running mdDOMAIN.MdDOMAINInstanceTest
In testCall()
Annotation: Indicators
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 s - in mdDOMAIN.MdDOMAINInstanceTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.238 s
[INFO] Finished at: 2022-10-21T20:14:46+11:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
Have you tried without Lombok in order to avoid this problem? Try doing manually in your test class what the Lombok annotation does instead.
After we have established that this solves the problem, we can start looking into possible workarounds. If this really is your first AspectJ problem, you should not start with a difficult mix like AspectJ + Lombok.
Besides, if your #Data class is immutable, you might not need Lombok at all and could use a recent Java version and native Java records for that.
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 need to execute two test cases using parallel testing in Cucumber.
What I have now is two test cases. One will open google.com and the other will open youtube.com. I've added certain dependencies in pom.xml and made some configs.
Also I've added the runner classes.
This is the google test case, runner class and feature file contents:
package com.cucumber.learning;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import cucumber.api.java.en.Given;
public class GoogleTest {
public static WebDriver driver = new FirefoxDriver();
#Given("go to google")
public static void main() {
driver.get("https://www.google.co.in/?gfe_rd=cr&ei=iHJrV_DiJ8SL8QfEipjgBg");
}
}
google runner class
package com.cucumber.learning;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/test/resources/com/cucumber/learning"
//,glue={"stepDefinition"}
)
public class GoogleRunnerIT {
}
google feature file: [feature file name: 1.google.feature]
#Google
Feature: Google test
Scenario: navigate to google
Given go to google
I've made similar to above code for youtube.com test case also.
the pom.xml code is as shown below:
<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.bdd</groupId>
<artifactId>CucumberModule</artifactId>
<version>0.0.1-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.1.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.1.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<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.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*RunnerIT.class</include>
</includes>
<parallel>all</parallel>
<threadCountSuites>2</threadCountSuites>
<useUnlimitedThreads>true</useUnlimitedThreads>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I execute the above project in Eclipse using "Run as 'Maven Test'", I receive the BUILD SUCCESS message but no browser is opening or the test case is executing.
Any help is greatly appreciated. Thanks in advance.
Console Error:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.bdd:CucumberModule:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 39, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building CucumberModule 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # CucumberModule ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/test/workspace/customparalleltesting/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # CucumberModule ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # CucumberModule ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # CucumberModule ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) # CucumberModule ---
[INFO] Surefire report directory: /home/test/workspace/customparalleltesting/target/surefire-reports
[INFO] Using configured provider org.apache.maven.surefire.junitcore.JUnitCoreProvider
[INFO] parallel='none', perCoreThreadCount=true, threadCount=0, useUnlimitedThreads=false, threadCountSuites=0, threadCountClasses=0, threadCountMethods=0, parallelOptimized=true
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.cucumber.learning.YoutubeTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.003 sec <<< FAILURE! - in com.cucumber.learning.YoutubeTest
initializationError(com.cucumber.learning.YoutubeTest) Time elapsed: 0.001 sec <<< ERROR!
cucumber.runtime.CucumberException:
Classes annotated with #RunWith(Cucumber.class) must not define any
Step Definition or Hook methods. Their sole purpose is to serve as
an entry point for JUnit. Step Definitions and Hooks should be defined
in their own classes. This allows them to be reused across features.
Offending class: class com.cucumber.learning.YoutubeTest
at cucumber.runtime.junit.Assertions.assertNoCucumberAnnotatedMethods(Assertions.java:13)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:55)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runner.Computer.getRunner(Computer.java:40)
at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87)
at org.junit.runners.Suite.<init>(Suite.java:80)
at org.junit.runner.Computer.getSuite(Computer.java:28)
at org.junit.runner.Request.classes(Request.java:75)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:97)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:78)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:144)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Running com.cucumber.learning.GoogleTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE! - in com.cucumber.learning.GoogleTest
initializationError(com.cucumber.learning.GoogleTest) Time elapsed: 0 sec <<< ERROR!
cucumber.runtime.CucumberException:
Classes annotated with #RunWith(Cucumber.class) must not define any
Step Definition or Hook methods. Their sole purpose is to serve as
an entry point for JUnit. Step Definitions and Hooks should be defined
in their own classes. This allows them to be reused across features.
Offending class: class com.cucumber.learning.GoogleTest
at cucumber.runtime.junit.Assertions.assertNoCucumberAnnotatedMethods(Assertions.java:13)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:55)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runner.Computer.getRunner(Computer.java:40)
at org.junit.runner.Computer$1.runnerForClass(Computer.java:31)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101)
at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87)
at org.junit.runners.Suite.<init>(Suite.java:80)
at org.junit.runner.Computer.getSuite(Computer.java:28)
at org.junit.runner.Request.classes(Request.java:75)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.createRequestAndRun(JUnitCoreWrapper.java:97)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.executeEager(JUnitCoreWrapper.java:78)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:54)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:144)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Results :
Tests in error:
GoogleTest.initializationError » Cucumber
Classes annotated with #RunWith(Cu...
YoutubeTest.initializationError » Cucumber
Classes annotated with #RunWith(C...
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.375 s
[INFO] Finished at: 2016-06-23T16:21:53+05:30
[INFO] Final Memory: 10M/218M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project CucumberModule: There are test failures.
[ERROR]
[ERROR] Please refer to /home/test/workspace/customparalleltesting/target/surefire-reports for the individual test results.
[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
There are many things which are not correct in your setup, you have to instantiate the browser from cucumber runner class so that all your step definitions can run in that instance any how if you want to run it separately, you have to do something like this :
package com.cucumber.learning;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import cucumber.api.java.en.Given;
public class GoogleTest extends GoogleRunnerIT {
#Given("go to google")
public static void main() {
public static WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.co.in/?gfe_rd=cr&ei=iHJrV_DiJ8SL8QfEipjgBg");
}
}
But efficient way is create a common method in runner class for instantiating and passing the url of your app.!
Try to put forkCount in the configuration tag of the maven-surefire plugin
With forkCount=4 as in below example it will run 4 Test Classes in parallel which ends with RunnerIT
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>acceptance-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<includes>
<include>**/*RunnerIT.class</include>
</includes>
<forkCount>4</forkCount>
<parallel>all</parallel>
<threadCountSuites>2</threadCountSuites>
<useUnlimitedThreads>true</useUnlimitedThreads>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</execution>
</executions>
</plugin>
Reference From :-
https://opencredo.com/running-cucumber-jvm-tests-in-parallel/
Can you change the signature and annotation for the method to be executed in step definition class
#Given("^go to google$")
public void goToGoogle() {
driver.get("https://www.google.co.in/gfe_rd=cr&ei=iHJrV_DiJ8SL8QfEipjgBg");
}
I am having doubt with the step definition being defined in main method.
I have an application which I'm testing using Selenium WebDriver and TestNG.
I have 15 methods which are marked with #Test annotations.
When i'm starting tests clicking on tests with mouse right button all 15 tests completing successfully, but when I'm starting tests using command-line with "mvn test" Maven output is:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.company.tests:Selenium:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 43, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Selenium 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # Selenium ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Selenium ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # Selenium ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 5 source files to C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.5:test (default-test) # Selenium ---
[INFO] Surefire report directory: C:\Users\ai\mysel\alexander-aut-webdriver-selenium\fwk\java\trunk\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Starting ChromeDriver (v2.9.248315) on port 21287
Tests run: 22, Failures: 2, Errors: 0, Skipped: 12, Time elapsed: 26.223 sec <<< FAILURE!
Results :
Failed tests:
openLoginPage(com.company.selenium.tests.LoginTest)
openRegistrationPage(com.company.selenium.tests.RegistrationTest)
Tests run: 22, Failures: 2, Errors: 0, Skipped: 12
openLoginPage() and openRegistration even not marked as #Test, they marked with #BeforeMethod annotation
why there are 22 tests when i running in maven?
how can i fix this so maven will run all 15 tests
I'd recommend you the following:
1) take a look at your project POM.xml : http://gyazo.com/7a9015de5e0f9801848e9ecba62a18e9
and make sure you've got following dependencies in your POM.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.41.0</version>
</dependency>
......
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
..........
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</dependency>
</dependencies>
2) 2nd step is to navigate to your project folder (exact one where POM.xml file is located) .
Open command window and run there
mvn clean test
http://gyazo.com/9526e807be8a6fc4ad6211d4aab19b5c
3) also pay attention to build/plugins section in POM.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
Probably the root cause is in <version>2.3.2</version> this one as far as I can understand from you log provided:
ests:Selenium:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. # line 43, column 21
Hope this helps you.
I currently use Eclipse as my Java IDE and I use Maven. I click the run button and it is able to run a Selenium Java test I wrote.
I then proceeded to install Maven on my local machine.
After going to the directory where my pom.xml file is located.
I run the command: mvn test
I receive the following results:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBu
ilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SeleniumWebDriver 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # SeleniumWebDriver ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.139 s
[INFO] Finished at: 2014-03-17T14:12:27-05:00
[INFO] Final Memory: 12M/99M
[INFO] ------------------------------------------------------------------------
I do not understand why the Firefox webbrowser does not start, and a test is ran. When running the same test in the Eclipse IDE the Firefox webBrowser does start.
It seems to compile fine, but it is for some reason not testing or kicking off the browser when it has the .class files after compilation.
here is a copy of 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>SeleniumWebDriver</groupId>
<artifactId>SeleniumWebDriver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
This is a older thread, but still want to provide input for those who are stuck up at this. You have to make sure that the class file names you are creating are ending with "Test" string.
e.g. AppTest, TempTest are all valid class file names, but AppCheck, TempTest1 are invalid name; maven will not detect these files for execution.
I would recommend using Maven Failsafe (for integration tests), or Surefire (for unit tests).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
I didn't see this until after I had posted my own question...and subsequently found an answer to it! I've included my answer below:
Maven can be made to run the code it compiles by using the exec-maven-plugin and adding the following to the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>Selenium2Example</mainClass>
<arguments>
<argument>arg0</argument>
<argument>arg1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
As you can probably gather from the snippet, arguments can be passed in by listing them in the pom.xml. Also, be sure to use the proper package name in the mainClass element.
You can then run mvn compile followed by mvn test to compile and run your code.
Credit has to go to http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ for listing several ways to do this.
This is most likely due to your directory structure. Maven uses an arbitrary directory structure.
src/main/java is your main java code
src/test/java is your tests. Maven will read THIS directory when executing mvn test by default.
You have two options:
Update your pom to something like:
<build>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
...
</build>
Abide by Maven convention and put your test sources under src/test/java