Re: [Cucumber] Tests not getting picked up while running from command line through maven

8,055 views
Skip to first unread message

aslak hellesoy

unread,
Nov 7, 2012, 4:21:12 PM11/7/12
to Cucumber Users



On Wed, Nov 7, 2012 at 7:09 PM, hari haran <hari.s...@gmail.com> wrote:
Hi All,

I am new to Cucumber-jvm. I am not able to find the cause of this issue.Please help me in this.

I added the cucumber dependencies in maven pom.xml through eclipse. And then I took the cucumber example and I ran the tests through TestRunner. So when I ran the TestRunner class in eclipse as Junit test the tests ran and gave me the result. 


Instead of describing your code, show it.

Aslak
 
Whereas test cases are not getting picked up for run while running the Test Runner class from command prompt. It always shows the following results.


C:\Documents and Settings\hkraman\workspace\com.tests>mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.tests 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ com.tests
---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Documents and Settings\hkraman\wor
kspace\com.tests\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ com.tests ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ co
m.tests ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ com.t
ests ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ com.tests ---
[INFO] Surefire report directory: C:\Documents and Settings\hkraman\workspace\co
m.tests\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.188s
[INFO] Finished at: Thu Nov 08 00:24:21 IST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------


Please somehpw tell me steps to follow for running Cucumber-jvm tests from command prompt.

--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
 
 

hari haran

unread,
Nov 7, 2012, 11:47:58 PM11/7/12
to cu...@googlegroups.com
And i used mvn test to run the test from command line.


On Thursday, 8 November 2012 00:39:38 UTC+5:30, hari haran wrote:
Hi All,

I am new to Cucumber-jvm. I am not able to find the cause of this issue.Please help me in this.

I added the cucumber dependencies in maven pom.xml through eclipse. And then I took the cucumber example and I ran the tests through TestRunner. So when I ran the TestRunner class in eclipse as Junit test the tests ran and gave me the result. 

hari haran

unread,
Nov 8, 2012, 9:25:51 AM11/8/12
to cu...@googlegroups.com
This is my RunClass file : RunTests.java

package Tests.com;
import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;
     
@RunWith(Cucumber.class)
@Cucumber.Options(format={"pretty", "json:./../../../../jenkins/jobs/ServicesTest/workspace/cucumber.json"})
public class RunTests {
    }


This is my Source Test Class file:

public class AppTest {
       
public static int balance;   

    @Before()
    public void setDriver() {
        FirefoxDriver driver = new FirefoxDriver();
        driver.get("http://google.com");
        driver.quit();
}
    @Before(value="@UserAccounts")
    public void initialize() {
        balance=0;
    }
   
    @Given(value="^a User has no money in their account$")
    public void a_User_has_no_money_in_their_current_account() {
        assertEquals("The balance is zero.", balance,0);
        }
   

    @When(value="^(\\d*) is deposited in to the account$")
    public void is_deposited_in_to_the_account(int amount) {
        balance=balance+amount;
        }
              
    @Then(value="^the balance should be (\\d*)$")
    public void the_balance_should_be(int expectedBalance) {
        assertTrue("The expected balance was 500, but actually was: " +balance, balance == expectedBalance);
        }
    }

And here is my pom.xml:

<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>Tests</groupId>
  <artifactId>Tests.com</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>Tests.com</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.2</version>
                <configuration>
                    <configuration>
                            <includes>
                                <include>**/RunTests.java</include>
                            </includes>
                        </configuration>
                </configuration>
            </plugin>
        </plugins>
    </build>
 
  <dependencies>
  <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.24.1</version>
    </dependency>
    <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
  </dependencies>
  <repositories>
        <repository>
            <id>codehaus</id>
            <url>http://repository.codehaus.org</url>
        </repository>
        <repository>
            <id>cukes</id>
            <url>http://cukes.info/maven</url>
        </repository>
    </repositories>
</project>

aslak hellesoy

unread,
Nov 8, 2012, 9:33:14 AM11/8/12
to Cucumber Users
On Thu, Nov 8, 2012 at 2:25 PM, hari haran <hari.s...@gmail.com> wrote:
This is my RunClass file : RunTests.java


1) I answered you earlier today and you ignored my suggestion. Rename RunTests to RunTest.
2) Don't name your stepdefs class AppTest. It's *not* A JUnit test. Rename it to AppStepdefs.
 
--

hari haran

unread,
Nov 8, 2012, 10:02:44 AM11/8/12
to cu...@googlegroups.com
Thanks a lot Aslak. I didnt see the mail. After renaming the file from "RunTests.java" to "RunTest.java" it worked.

Thomas Sundberg

unread,
Nov 8, 2012, 3:06:20 PM11/8/12
to cu...@googlegroups.com
On 8 November 2012 16:02, hari haran <hari.s...@gmail.com> wrote:
> Thanks a lot Aslak. I didnt see the mail. After renaming the file from
> "RunTests.java" to "RunTest.java" it worked.

This was to be expected when using the Maven-Surefire-Plugin. It picks
up and executes some classes. Classes named Test* or *Test are picked
up. Classes named *Tests will not be picked up and executed.

/Thomas
--
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://thomassundberg.wordpress.com/
Twitter: @thomassundberg

Better software through faster feedback

Vinodh R

unread,
Jul 17, 2014, 10:18:29 AM7/17/14
to cu...@googlegroups.com
Hi Asklak,

I've the same issue., As per your solution, I've renamed the runner file and the step def file like this "CuckRunTest.jav", "NewLockStepdef.Java".

But still I'm getting the same issue.  Please see the below output in the command prompt.  Please let me know what mistake I'm doing here?

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar;

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building rpmweb2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rpmweb2 --
-

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory M:\Documents\Automation\Java\Cucumber
-JVM\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ rpmweb2 ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ rp
mweb2 ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ rpmwe
b2 ---

[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ rpmweb2 ---
[INFO] Surefire report directory: M:\Documents\Automation\Java\Cucumber-JVM\targ
et\surefire-reports
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.cs.rpmweb2.CukeRunTest
Configuring TestNG with: org.apache.maven.surefire.testng.conf.TestNG652Configur
ator@3c23af64
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.132 sec
Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\QUICKT~1\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\QUICKT~1\bin\JAVA_S~1\classes\jasmine.jar;
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.250 s
[INFO] Finished at: 2014-07-17T10:14:22-04:00
[INFO] Final Memory: 9M/123M

Thanks
Vinodh.R

Anand JOis

unread,
Jun 29, 2016, 12:09:04 PM6/29/16
to Cukes
Hi Vinodh,

Have you got any solution for this?

Thanks
Anand

kavitha kesavalu

unread,
Jul 24, 2016, 5:26:00 PM7/24/16
to Cukes
Did you get resoultion for this? I have same issue

morad khatteb

unread,
Nov 30, 2017, 10:56:03 AM11/30/17
to Cukes
I Found how to solve this:
1- Rename the Cuke runner to RunTest.java
2- put the file in  src/test/java/RunTest.java

Thanks
 

Koen Prins

unread,
Nov 30, 2017, 5:20:38 PM11/30/17
to cu...@googlegroups.com
Depending on your JUnit setup, the default is that JUnit will runn only those classes which end in *Test.java

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

sridevi ennam

unread,
Dec 6, 2017, 4:13:33 AM12/6/17
to cu...@googlegroups.com

Check your folder structure and pass the correct class path into CucumberOptions
Follow the instructions here for folder structure http://www.seleniumframework.com/cucumber-jvm-3/cucumber-jvm-folder-structure/

--
Posting rules: http://cukes.info/posting-rules.html
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
Reply all
Reply to author
Forward
0 new messages