Rerun.txt in Cucumber refers to classpath instead of Feature folder - java

I'm running Cucumber tests (with Maven, in Jenkins) and outputting failed scenario's to target/rerun.txt, as per these instructions: https://github.com/cucumber/cucumber-jvm/issues/890
It creates the rerun.txt and it inputs failed scenario's, but enters them as: features/name.feature:2. The rerun then tries to run them as classpath/name.feature, and fails to see they are in src/test/resources/features.
If I put the features files in the classpath instead, I get an inconsistent filters error (probably because I'm using tags in the first call and the text in the second call).
How to get Cucumber to either output the correct path for features, or to get it to find the features based on the rerun.txt?
The error:
Running com.xxx.cucumber._RunCukesTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.002 sec <<< FAILURE!
initializationError(com.xxx.cucumber._RunCukesTest) Time elapsed: 0 sec <<< ERROR!
java.lang.IllegalArgumentException: Neither found on file system or on classpath: Not a file or directory: classpath\SubFolder\Test1.feature,
No resource found for: classpath:SubFolder/Test1.feature
Additional info:
All initial calls to tests are done via tags.
All features are in subfolders in classpath/src/test/resources/features
This test has to run in Jenkins, automatically, every day.
The first run uses this:
#RunWith(Cucumber.class)
#CucumberOptions(
strict = false,
features={"src/test/resources/features/"},
snippets=SnippetType.CAMELCASE,
plugin = { "pretty", "json:target/cucumber-reports/test-report.json", "html:target/cucumber-reports",
"rerun:target/rerun.txt"})
public class RunCukesTest {
}
The second run of failed scenario's uses this:
#RunWith(Cucumber.class)
#CucumberOptions(
strict = false,
features={"#target/rerun.txt"},
snippets=SnippetType.CAMELCASE,
plugin = {"pretty", "json:target/cucumber-reports/test-report.json", "html:target/cucumber-reports"})
public class _RunCukesTest {
}

Change the feature file location of first test runner to features = "."
This will make 'rerun.txt' to be updated with correct path to the feature file.

Related

Jenkins is unable to locate file that can be located manually

When I added the commands that I use manually at the command prompt to run my project to Jenkins, Jenkins is unable to find the file that's referenced.
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.631 s <<< FAILURE! - in TestSuite
[ERROR] main(test.java.IterateToEAMethods) Time elapsed: 0.016 s <<< FAILURE!
java.io.FileNotFoundException: Q:\A_Parts routing\03_Systeme\Selenium\Vega Automatisierung Teil 1\AutomatisierterSteuerungsantrag.xls (The system cannot find the path specified)
at test.java.IterateToEAMethods.main(IterateToEAMethods.java:162)
When I run this project through the command line using the exact same commands it runs fine.
CD C:\Users\D171_o_QECJACK031\eclipse-workspace\VegaAutomatisierungPart2
mvn --settings settings.xml compile clean test
Does anyone know how to get Jenkins to have access to the file?
None of my other projects that use files have this problem and they run through Jenkins.
You need to replace \ with \\ when accessing paths in windows.
You could use dir with the path where your scripts are present :
// dir("<Your path where scripts are present>")
dir ("C:\\Users\\D171_o_QECJACK031\\eclipse-workspace\\VegaAutomatisierungPart2"){
<Your commands>
}

The JUnit test suite failes with [junit] ASSERTION FAILED: 'ci->bp_id == 0'

I have a JUnit test suite running on Jenkins.
The test suite uses the below technologies.
Ant to build
JMockint to Mock the EJBs
Jacoco for Code coverage
The test suite runs one a Jenkins Slave machine (unix), and runs for an average time of 45 mins (~1500 tests).
The test count in the suite gradually getting increased. Form recently I get the below error making the test run crash intermittently.
[junit]
[junit] ASSERTION FAILED: 'ci->bp_id == 0'
[junit] In cmReleaseCodeInfo() (src/jvm/runtime/code/memory/codecollector.c:454)
[junit] Assertion failed after 0 days, 00:32:50 on Mon Jan 23 11:14:50 2017
[junit] Running requires.testMis.MaskedCinTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit] Tests FAILED (crashed)
I'm not sure how to trace this. Would be glad if anyone has a clue/ or a lead to find whats going on.
Would be more interested to see from where [junit] ASSERTION FAILED: 'ci->bp_id == 0' is coming.
Would be more interested to see from where [junit] ASSERTION FAILED: 'ci->bp_id == 0' is coming.
I could not find this file. In fact I have a java project. The file showing above is C. This looks much more like lower level than Java. – Asanke 8 hours ago
Also the assertion shown above, I have not coded such in my project. – Asanke 8 hours ago
The assertion is compiled into a binary executable your code uses.
There are different approaches obout how to deal with this situation depending on what type of test you are executing.
If this is a regression test (or acceptance test) you may have discovered a bug: your code passes an invalid bp_id (what ever this is, you should know...).
If this is a UnitTest then you should mock the code that calls the binary executable.

Evosuite: failure in executing test cases

I follow the evosuite maven documentation to generate unit test cases for my project. Below is the command I've used:
mvn -DmemoryInMB=2000 -Dcores=2 evosuite:generate evosuite:export test
The tool takes around 1 hour to generate test cases for my project (with 9700 lines of Java code). However when it proceed to mvn test phase, all test cases failed with the same message:
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE! - in com.xxx.yyy.util.Messages_ESTest
com.xxx.yyy.util.Messages_ESTest Time elapsed: 0 sec <<< ERROR!
java.lang.IllegalStateException: Trying to set up the sandbox while executing a test case
at <evosuite>.<evosuite>(<evosuite>)
at <evosuite>.<evosuite>(<evosuite>)
at <evosuite>.<evosuite>(<evosuite>)
While running the generated test case in Intellij IDEA most of them can pass the test:
Any one got any idea?
this is clearly a bug, which would be best to report on
https://github.com/EvoSuite/evosuite/issues
furthermore, currently in 1.0.3 the tests generated by EvoSuite do not work well with "mvn test". The fix is already in the SNAPSHOT though, and will be part of next release. However, the "Trying to set up the sandbox" might be a new bug as I haven't seen it before... :(

Maven -Dtest=* test, does not seem to run all tests

I've got a Jenkins CI server that is set up with a Selenium test project running with maven-surefire. I need the project to be a parameterized build, so that I can trigger the build via URL with a Dtest as a parameter (and only run the tests I specify in the url). This works great.
Unfortunately, I've been unable to figure out how to run ALL of the tests, while in this parameterized configuration. Since it is in parameterized build mode, I must ALWAYS specify the -Dtest parameter.
Based on the Surefire documentation, it seems like I should be able to wildcard the test names, and everything will be run:
-Dtest=* or -Dtest=Test*
The odd result of running these parameters is a print statement (that I created) from all 6 of the tests (denoting that they were all started):
"Test <test_name> started, click here to see the SauceLabs video"
And then the standard test result (below) for only 4/6 tests
Running <test_class_path>
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.048 sec
Followed by the summary:
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0
If it matters, the tests are being run in parallel using surefire, and one other odd thing is that while printing out the individual test results, after the 4th one, the 5th result starts printing, but never shows a result, and includes a $1 at the end:
Running <test_class_path>$1
Please let me know if I can clarify anything or answer any questions.
Thanks in advance for any help!
I think that it's a regular expession:
mvn -Dtest=.*
works for me.

Error appears before running the Webdriver test on a Hudson slave

We are trying to migrate our system to WebDriver from Selenium 1.
Thorough the Hudson slave an error message appeared, but the test run fine in eclipse.
Environments:
Hudson master: Linux machine
Hudson slave: windows 7, x86
Java version: 1.7.0_03
System:
A new Hudson job was set up for the task, with the same configurations as it was for Selenium 1 test suites. The job executes a target from the build.xml file. clean,makedir and compile targets were ran successfully.
On executing the tests the following error message appeared on Hudson Console:
run_shopping_travel_tests:
[junit] Running com.example.tests.ExampleTests
[junit] Tests run: 1, Failures: 0, Errors: 2, Time elapsed: 2.385 sec
[junit] Test com.example.tests.ExampleTests FAILED
[junit] Running com.example.tests.Example2Test
[junit] Tests run: 1, Failures: 0, Errors: 2, Time elapsed: 0.752 sec
[junit] Test com.example.tests.Example2Test FAILED
[echo] selenium directory: C:\Selenium
The error:
Error Message
LINUX
Stacktrace
java.lang.NoSuchFieldError: LINUX
at org.openqa.selenium.firefox.FirefoxBinary.isOnLinux(FirefoxBinary.java:62)
at org.openqa.selenium.firefox.FirefoxBinary.startProfile(FirefoxBinary.java:72)
at org.openqa.selenium.firefox.FirefoxBinary.clean(FirefoxBinary.java:273)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:78)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:142)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:85)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:77)
at com.example.tests.ExampleTests.setup(ExampleTests.java:43)
The java code for the test:
public class ExampleTests
{
FirefoxDriver driver = null;
#Before
public void setup() {
File profileDir = new File( "C:\\Selenium\\FirefoxProfile" );
FirefoxProfile profile = new FirefoxProfile(profileDir);
driver = new FirefoxDriver(profile); // line 43, where error appears
}
#Test
public void T100_VerifyExampleTest() {
// some test code here
}
}
We have tried to run the test without "profile" and the same error message appeared.
Thanks in advance.
Problem solved.
There were some jar libraries included which were used for compiling by -javac (in the ant script), but not by eclipse.
Solution:
Check the jar files one-by-one,and delete the unnecessary ones from the lib folder.

Categories