Re: [Cucumber] [JVM]: Not able to run my cucumber tests through Maven

5,939 views
Skip to first unread message

Aslak Hellesøy

unread,
Apr 19, 2013, 2:19:27 AM4/19/13
to cu...@googlegroups.com

On Friday, 19 April 2013 at 05:36, Prashanth T.V wrote:

Hi Aslak/All,

I have been using Cucumber with JVM recently and I was successfully able to run my cucumber tests through eclipse. I'm very new to Maven. When I compile and run my tests through Maven, it shows as Build Success, But no tests are getting picked and it is not run.
By default, Maven only picks up test classes that end with Test. All you need to do is to rename Runner to e.g. RunCukesTest. Also, lose the main method.

Aalak
Could you please help me in this regard.
I have been using Cucumber with Java and have used cucumber jars along with Selenium jars in my dependency list in POM.XML

Please find attached, the screen shot of my eclipse project(which indicates the folder structure of my project) and my POM.XML as well for your reference.

Below is the stack trace when I ran it from the command prompt:


E:\prashanth\mvntimesgroup>mvn integration-test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mvntimesgroup 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-test-source (add-source) @ mvntimes
group ---
[INFO] Test Source directory: E:\prashanth\mvntimesgroup\src\test\java added.
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-test-resource (add-resource) @ mvnt
imesgroup ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mvntimesgr
oup ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\prashanth\mvntimesgroup\src\main\r
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mvntimesgroup -
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ mv
ntimesgroup ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mvntime
sgroup ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.14.1:test (default-test) @ mvntimesgroup ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ mvntimesgroup ---
[INFO] Building jar: E:\prashanth\mvntimesgroup\target\cuke-jvm-example.jar
[INFO]
[INFO] >>> jetty-maven-plugin:8.1.10.v20130312:run (start-jetty) @ mvntimesgroup
 >>>
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-test-source (add-source) @ mvntimes
group ---
[INFO] Test Source directory: E:\prashanth\mvntimesgroup\src\test\java added.
[INFO]
[INFO] --- build-helper-maven-plugin:1.8:add-test-resource (add-resource) @ mvnt
imesgroup ---
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mvntimesgr
oup ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\prashanth\mvntimesgroup\src\main\r
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mvntimesgroup -
--
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ mv
ntimesgroup ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mvntime
sgroup ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] <<< jetty-maven-plugin:8.1.10.v20130312:run (start-jetty) @ mvntimesgroup
 <<<
[INFO]
[INFO] --- jetty-maven-plugin:8.1.10.v20130312:run (start-jetty) @ mvntimesgroup
 ---
[INFO] Configuring Jetty for project: mvntimesgroup
[INFO] webAppSourceDirectory not set. Defaulting to E:\prashanth\mvntimesgroup\s
rc\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = E:\prashanth\mvntimesgroup\target\classes
[INFO] Context path = /
[INFO] Tmp directory = E:\prashanth\mvntimesgroup\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =  none
[INFO] web.xml file = null
[INFO] Webapp directory = E:\prashanth\mvntimesgroup\src\main\webapp
2013-04-19 10:00:16.564:INFO:oejs.Server:jetty-8.1.10.v20130312
2013-04-19 10:00:20.639:INFO:oejpw.PlusConfiguration:No Transaction manager foun
d - if your webapp requires one, please configure one.
2013-04-19 10:01:46.872:INFO:oejs.AbstractConnector:Started SelectChannelConnect
[INFO] Started Jetty Server
[INFO]
[INFO] --- maven-failsafe-plugin:2.12:integration-test (integration-test) @ mvnt
imesgroup ---
[INFO] Failsafe report directory: E:\prashanth\mvntimesgroup\target\failsafe-rep
orts

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

Results :

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

[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:36.468s
[INFO] Finished at: Fri Apr 19 10:01:47 IST 2013
[INFO] Final Memory: 39M/395M
[INFO] ------------------------------------------------------------------------
2013-04-19 10:01:48.490:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purg
ed
2013-04-19 10:01:48.492:INFO:oejsh.ContextHandler:stopped o.m.j.p.JettyWebAppCon
text{/,file:/E:/prashanth/mvntimesgroup/src/main/webapp},file:/E:/prashanth/mvnt
imesgroup/src/main/webapp


Regards
Prashanth


--
-- 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
---
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+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Attachments:
- pom.xml

Jason Smiley

unread,
Apr 19, 2013, 12:00:14 PM4/19/13
to cu...@googlegroups.com
I don't understand what you are telling us to do Aslak.

I have been using maven to run test scripts but when I updated to 1.13 everything stopped working. I am currently using 1.12 again as I couldn't figure out why no tests were running.

Can you please use a code example?

I am assuming something here needs to be changed.

Code for CucumberTest.java: 

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@Cucumber.Options(tags={"@test"}, format = {"pretty", "json:target/json-report.json", "junit:target/junit-report.xml", "html:target/html"})
public class CucumberTest {
}

What I am seeing when I use the latest cucumber is the maven code compiling but 0 tests being run (says -1 tests run in report). Any help would be much appreciated.

On Friday, April 19, 2013 12:36:02 AM UTC-4, Prashanth T.V wrote:
Hi Aslak/All,

I have been using Cucumber with JVM recently and I was successfully able to run my cucumber tests through eclipse. I'm very new to Maven. When I compile and run my tests through Maven, it shows as Build Success, But no tests are getting picked and it is not run. Could you please help me in this regard.

aslak hellesoy

unread,
Apr 19, 2013, 12:18:21 PM4/19/13
to Cucumber Users
On Fri, Apr 19, 2013 at 5:00 PM, Jason Smiley <jason....@1stdibs.com> wrote:
I don't understand what you are telling us to do Aslak.

I have been using maven to run test scripts but when I updated to 1.13 everything stopped working. I am currently using 1.12 again as I couldn't figure out why no tests were running.

Can you please use a code example?

It would be better if you could share a minimal project on Github that illustrates the problem. Then I can try to fix it.

Aslak
 

Jason Smiley

unread,
Apr 19, 2013, 12:26:01 PM4/19/13
to cu...@googlegroups.com
I am not really sure what you are looking for. Also, I don't know what the error is, I can copy and paste the output I mentioned, but all I changed in my project was the POM.xml for 1.12 to 1.13.

Do you want me to upload my POM?

aslak hellesoy

unread,
Apr 19, 2013, 12:31:08 PM4/19/13
to Cucumber Users
On Fri, Apr 19, 2013 at 5:26 PM, Jason Smiley <jason....@1stdibs.com> wrote:
I am not really sure what you are looking for.

I'm surprised you find my replies so hard to understand. Since you joined this thread I'm going to assume that you and the OP (Prashanth) are working together.

What I need is for you to put some code in a git repo that someone can clone, and see the same problems as you.
Also, please read the 3 rules we have on this list, especially 2.

Thanks,
Aslak

Jason Smiley

unread,
Apr 19, 2013, 12:37:34 PM4/19/13
to cu...@googlegroups.com
I am not with the OP - I will see if I can get you a github repo to use - currently its under my company repo (private).

In the meantime, I attached a few key files for you to look at.
pom.xml
CucumberTest.java
Setup_Teardown_steps.java

aslak hellesoy

unread,
Apr 19, 2013, 12:44:12 PM4/19/13
to Cucumber Users
On Fri, Apr 19, 2013 at 5:37 PM, Jason Smiley <jason....@1stdibs.com> wrote:
I am not with the OP - I will see if I can get you a github repo to use - currently its under my company repo (private).

In the meantime, I attached a few key files for you to look at.


Please make it easier for me.
I'll only look if you give me a git URL I can clone. Cobbling together files is too much work, and I can't give feedback as easily on files attached in an email.

Aslak

Jason Smiley

unread,
Apr 19, 2013, 12:56:04 PM4/19/13
to cu...@googlegroups.com

Jason Smiley

unread,
Apr 19, 2013, 1:01:42 PM4/19/13
to cu...@googlegroups.com
btw, the code is currently using 1.12 - so its working at the moment. I will update for you so it can be "broken"

Jason Smiley

unread,
Apr 19, 2013, 1:29:53 PM4/19/13
to cu...@googlegroups.com
let me know if you have any issues with my project.

Paolo Ambrosio

unread,
Apr 19, 2013, 2:26:23 PM4/19/13
to cu...@googlegroups.com
On Fri, Apr 19, 2013 at 6:29 PM, Jason Smiley <jason....@1stdibs.com> wrote:

> let me know if you have any issues with my project.

Your project does not compile.

After removing everything that wasn't compiling (step definitions,
page objects, etc.). I was able to run Cucumber from your project with
"mvn test". Cucumber runs, so I don't think there is any problem with
your pom.


Paolo

Jason Smiley

unread,
Apr 19, 2013, 3:00:55 PM4/19/13
to cu...@googlegroups.com
I just realized that the pom uses a private library (my company's shared library) - let me remove this.

Jason Smiley

unread,
Apr 19, 2013, 3:03:25 PM4/19/13
to cu...@googlegroups.com
This is what I see when I run:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running CucumberTest
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.

@selenium @browse
Feature: Browse Tests
  As a user
  I should be able to browser through all products
  filter my results
  and click an item to view the Product Detail Page.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.532 sec <<< FAILURE!

Results :

Tests in error: 
  Feature: Browse Tests: -1

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

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.135s
[INFO] Finished at: Fri Apr 19 15:02:18 EDT 2013
[INFO] Final Memory: 19M/233M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project Cucumber_Automation: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/jason/Desktop/github/test-scripts/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:

Jason Smiley

unread,
Apr 19, 2013, 3:07:54 PM4/19/13
to cu...@googlegroups.com
I removed the Report_steps.java file which is the only file which uses my company's shared library. You should be able to recreate my issue now.

aslak hellesoy

unread,
Apr 19, 2013, 3:28:43 PM4/19/13
to Cucumber Users
On Fri, Apr 19, 2013 at 8:03 PM, Jason Smiley <jason....@1stdibs.com> wrote:
This is what I see when I run:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running CucumberTest
log4j:WARN No appenders could be found for logger (org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager).
log4j:WARN Please initialize the log4j system properly.

@selenium @browse
Feature: Browse Tests
  As a user
  I should be able to browser through all products
  filter my results
  and click an item to view the Product Detail Page.
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.532 sec <<< FAILURE!

Results :

Tests in error: 
  Feature: Browse Tests: -1

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


The topic of this thread is a question about why no cucumber tests were run.
It's obvious from the output you have pasted here that 1 test is running.

Problem solved?
 

--

Jason Smiley

unread,
Apr 19, 2013, 3:35:58 PM4/19/13
to cu...@googlegroups.com
I don't mind making a new thread and saying "My tests are not actually being executed for some reason when I launch through maven using cucumber 1.1.3"

But, when I use 1.1.3, I get the previous output. Using 1.1.2, it works just fine. I thought this was the same issue, maybe I was wrong. I will create a new thread if you believe the issues are different.
-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

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

[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. b
uild is platform dependent!
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1:36.468s
[INFO] Finished at: Fri Apr 19 10:01:47 IST 2013
[INFO] Final Memory: 39M/395M
[INFO] ------------------------------------------------------------------------
2013-04-19 10:01:48.490:INFO:oejsl.ELContextCleaner:javax.el.BeanELResolver purg
ed
2013-04-19 10:01:48.492:INFO:oejsh.ContextHandler:stopped o.m.j.p.JettyWebAppCon
text{/,file:/E:/prashanth/mvntimesgroup/src/main/webapp},file:/E:/prashanth/mvnt
imesgroup/src/main/webapp


Regards
Prashanth


Jason Smiley

unread,
Apr 19, 2013, 3:39:12 PM4/19/13
to cu...@googlegroups.com
ah, this is different, my mistake. Opening a new thread.

Paolo Ambrosio

unread,
Apr 19, 2013, 3:48:29 PM4/19/13
to cu...@googlegroups.com
On Fri, Apr 19, 2013 at 8:07 PM, Jason Smiley <jason....@1stdibs.com> wrote:
> I removed the Report_steps.java file which is the only file which uses my
> company's shared library. You should be able to recreate my issue now.

Yes, now it compiles. If you read the output, it says...

[ERROR] Please refer to
/Users/jason/Desktop/github/test-scripts/target/surefire-reports for
the individual test results.

In that directory then you can find a CucumberTest.txt file with the
error. It looks very much like bug #491:

https://github.com/cucumber/cucumber-jvm/issues/491


Paolo

Prashanth T.V

unread,
Apr 21, 2013, 7:03:53 AM4/21/13
to cu...@googlegroups.com
Hello Aslak,

Thanks a lot for your reply. As you had suggested, I renamed my Runner.java to RunCukesTest.java
I also removed the main method in my RunCukesTest.java.
Now, this is how my RunCukesTest.java file looks:

package com.cucumber.timescity.login;

import org.junit.runner.RunWith;

import cucumber.api.java.it.Date;
import cucumber.api.junit.Cucumber;

// runner class

@RunWith(Cucumber.class)
@Cucumber.Options(format={"html:output"})
public class RunCukesTest {
}


Note:1)  When I ran my tests through mvn using the command "mvn integration-test", it was able to launch the browser successfully and was able to go to the website "timescity.com". But, for some reason, it was not able to click on the Login link. But, when I ran my same test directly through eclipse, I was able run my test successfully.

2) Now, If I give a command "mvn clean" and then "mvn compile", it performs the operation successfully and it says "Build Success" in my command prompt console. But after this, when I give the command "mvn integration-test", it shows Build-Failure"

Please find my complete project which has been uploaded to Github for your refrence.


Please find attached, the error log after I ran the "integration-test" command(error console_maven.txt)

Regards
Prashanth
error console_maven run.txt

Paolo Ambrosio

unread,
Apr 21, 2013, 3:22:22 PM4/21/13
to cu...@googlegroups.com
On Sun, Apr 21, 2013 at 12:03 PM, Prashanth T.V <prash...@gmail.com> wrote:

> Note:1) When I ran my tests through mvn using the command "mvn
> integration-test", it was able to launch the browser successfully and was
> able to go to the website "timescity.com". But, for some reason, it was not
> able to click on the Login link. But, when I ran my same test directly
> through eclipse, I was able run my test successfully.

Good. This proves that Cucumber is set up correctly and that it is
just a Maven misconfiguration.

> 2) Now, If I give a command "mvn clean" and then "mvn compile", it performs
> the operation successfully and it says "Build Success" in my command prompt
> console. But after this, when I give the command "mvn integration-test", it
> shows Build-Failure"

I would say that you have to add the test classpath scope to the exec
plugin. Again, this does not seem related to Cucumber.

You can find examples of Maven setup for Cucumber in this mailing
list, in the example directory or just using Google. Also consider
reading the documentation for the Maven plugin you are using, as they
are generally quite detailed.


Paolo

Prashanth T.V

unread,
Apr 21, 2013, 11:57:32 PM4/21/13
to cu...@googlegroups.com
Hi Paolo,

Tried all possibilities and googled lot of maven related stuff. But, for some reason, the issue is still persisting.

Paolo Ambrosio

unread,
Apr 22, 2013, 2:38:26 AM4/22/13
to cu...@googlegroups.com
On Mon, Apr 22, 2013 at 4:57 AM, Prashanth T.V <prash...@gmail.com> wrote:

> Tried all possibilities and googled lot of maven related stuff. But, for
> some reason, the issue is still persisting.

If I run "mvn integration-test" in the example on github I see a
different error as cucumber-core has a different version from the
other dependencies (and scope, but that is not related to the error).
Solved the problem, I see a null pointer exception in
WebConnector.java:89 as your CONFIG object is null.

There are a series of different errors on your code every time you ask
for help. Perhaps it might be easier to change an already working
example to fit your needs.


Paolo

Prashanth T.V

unread,
Apr 22, 2013, 2:56:52 AM4/22/13
to cu...@googlegroups.com
Thanks Paolo a lot for your reply.

Well..Regarding the error in my code, When I run the cucumber tests manually through eclipse, It works fine and it is able to open the browser and and it works perfectly.

So, I was a bit confused as to why it was not working through Maven.

Actually, the issue is that, When I do a "mvn integration-test", it opens the browser and logs in. But when I do a mvn clean and then do a mvn integration-test, it does not work. Is there any issue with my pom.xml

Prashanth T.V

unread,
Apr 24, 2013, 12:05:41 AM4/24/13
to cu...@googlegroups.com
Hi Aslak,

Did you get a chance to look into my cucumber project which I had posted in github. Can you please let me know as to what the issue is.

Aslak Hellesøy

unread,
Apr 24, 2013, 1:20:56 AM4/24/13
to cu...@googlegroups.com

On Wednesday, 24 April 2013 at 05:05, Prashanth T.V wrote:

Hi Aslak,

Did you get a chance to look into my cucumber project which I had posted in github.
I didn't Prashant. 

Everyone, please don't ask individuals for help on this list. Address the crowd.

I'm considering adding this as a new list rule.

Aslak 
Reply all
Reply to author
Forward
0 new messages