Closed aravindkesavarapu closed 3 years ago
Hi @aravindkesavarapu
Did you try updating your surefire plugin to include your Courgette runner?
Something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<includes>
<!-- Add the path to your Courgette runner here -->
<include>**/suites/ScenarioSuite.class</include>
</includes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M5</version>
</dependency>
</dependencies>
</plugin>
Hi @prashant-ramcharan,
Thanks for the reply :),
I updated the surefire plugin in pom.xml as you suggested. If I run one test case it is working fine. but when I run more than one test case using the maven command it is not giving an exact report. I have attached the HTML & maven screenshots
I ran three test cases in that 1 passed & 2 failed. the same thing generating on html file
But in maven it is showing test run as 2 in Running courgette.api.junit.Courgette & under results it is showing test run 1
Please let me know if you need any information.
Thanks, Aravind
Hi @prashant-ramcharan ,
I have observed that both the scenarios are in one feature file at that time the maven calculating only one test case failed.
example - 1: fileOne.feaure
In this above(example1) case Running courgette.api.junit.Courgette: Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 2.014 s - in courgette.api.junit.Courgette
Maven: Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
example - 2:
fileThree.feature:
fileFour.feature
fileFive.feature
In this above result Running courgette.api.junit.Courgette [ERROR] Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 2.086 s <<< FAILURE! - in courgette.api.junit.Courgette Maven: [ERROR] Tests run: 3, Failures: 0, Errors: 3, Skipped: 0
And Stack trace is also not displaying. Instead of stack trace it is displaying {featureName} failed. Please find the below screenshot
Thanks, Aravind
Hi @aravindkesavarapu
This is as expected. Maven counts the number of feature files so in the below scenario:
feature1.feature (has 1 scenario)
feature2.feature (has 2 scenarios)
feature3.feature (has 3 scenarios)
With regards to the test failure stacktrace, this will be available in the Cucumber and Courgette reports. If Maven were to fail then it's stacktrace will be shown in the console and not the actual test failure stacktrace.
Hi @prashant-ramcharan,
Jenkins was not recording the correct failure test case stacktrace. please find the below screenshot.
I have observed that courgette-jvm generating different format of JSON for Scenario outline. is this expected?
Thanks, aravind
Hi @aravindkesavarapu
I'm not sure I follow. Can you please share a project to describe this issue ?
Hi @prashant-ramcharan
Sorry for the late reply.
I tried on the sample courgette-jvm-maven-example
Please find the attached courgette & cucumber JSON files.
Courgette-JVM Json: What I have observed is for Scenario outline type json results. It is appending feature file details for every example at the end.
[
{
"line": 2,
"elements": [
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 5575549900,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:28:51.543Z",
"before": [
{
"result": {
"duration": 19986566000,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 14,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;2",
"after": [
{
"result": {
"duration": 1836170600,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 7700295500,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 3",
"match": {
"arguments": [
{
"val": "3",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 28402200,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 3 is opened",
"match": {
"arguments": [
{
"val": "3",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithcourgette"
}
]
}
],
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
]
},
{
"line": 2,
"elements": [
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 3750175200,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:29:32.678Z",
"before": [
{
"result": {
"duration": 9484562200,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 16,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;4",
"after": [
{
"result": {
"duration": 1488752300,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 211613987900,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 5",
"match": {
"arguments": [
{
"val": "5",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 29911600,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 5 is opened",
"match": {
"arguments": [
{
"val": "5",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithcourgette"
}
]
}
],
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
]
},
{
"line": 2,
"elements": [
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 3910078700,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:29:33.124Z",
"before": [
{
"result": {
"duration": 9130217500,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 15,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;3",
"after": [
{
"result": {
"duration": 1178716500,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 3380072000,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 4",
"match": {
"arguments": [
{
"val": "4",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 18475700,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 4 is opened",
"match": {
"arguments": [
{
"val": "4",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithcourgette"
}
]
}
],
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
]
}
]
In above JSON file this block is repeating 3 times(based upon the examples in scenario):
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
Cucumber JSON: where as in cucumber json file it is appending at the end of all example.
[
{
"line": 2,
"elements": [
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 2539442700,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:44:38.169Z",
"before": [
{
"result": {
"duration": 5447818200,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 14,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;2",
"after": [
{
"result": {
"duration": 959684700,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 4597411800,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 3",
"match": {
"arguments": [
{
"val": "3",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 50150400,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 3 is opened",
"match": {
"arguments": [
{
"val": "3",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithoutcourgette"
}
]
},
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 1867556700,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:44:51.968Z",
"before": [
{
"result": {
"duration": 4283871300,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 15,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;3",
"after": [
{
"result": {
"duration": 1054660900,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 1676526700,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 4",
"match": {
"arguments": [
{
"val": "4",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 30865900,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 4 is opened",
"match": {
"arguments": [
{
"val": "4",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithoutcourgette"
}
]
},
{
"line": 4,
"name": "",
"description": "",
"type": "background",
"keyword": "Background",
"steps": [
{
"result": {
"duration": 2439281500,
"status": "passed"
},
"line": 5,
"name": "I navigate to Stack Overflow",
"match": {
"location": "steps.TestSteps.iNavigateToStackOverflow()"
},
"keyword": "Given "
}
]
},
{
"start_timestamp": "2021-11-30T14:45:00.912Z",
"before": [
{
"result": {
"duration": 4031735400,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.before()"
}
}
],
"line": 16,
"name": "Ensure that stack overflow question pages can be opened",
"description": "",
"id": "feature-with-examples;ensure-that-stack-overflow-question-pages-can-be-opened;;4",
"after": [
{
"result": {
"duration": 1063712000,
"status": "passed"
},
"match": {
"location": "steps.TestSteps.after(io.cucumber.java.Scenario)"
}
}
],
"type": "scenario",
"keyword": "Scenario Outline",
"steps": [
{
"result": {
"duration": 1397006000,
"status": "passed"
},
"line": 9,
"name": "I navigate to Stack Overflow question page 5",
"match": {
"arguments": [
{
"val": "5",
"offset": 43
}
],
"location": "steps.TestSteps.i_navigate_to_Stack_Overflow_question_page(java.lang.Integer)"
},
"keyword": "When "
},
{
"result": {
"duration": 18974800,
"status": "passed"
},
"line": 10,
"name": "I verify Stack Overflow question page 5 is opened",
"match": {
"arguments": [
{
"val": "5",
"offset": 38
}
],
"location": "steps.TestSteps.i_verify_Stack_Overflow_question_page_is_opened(java.lang.Integer)"
},
"keyword": "Then "
}
],
"tags": [
{
"name": "@regression"
},
{
"name": "@testwithoutcourgette"
}
]
}
],
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
]
}
]
Where as in cucumber json file it is appending at the end of the scenario result. It means at the end of the result
"name": "Feature with Examples",
"description": "",
"id": "feature-with-examples",
"keyword": "Feature",
"uri": "file:src/test/resources/features/FeatureWithExamples.feature",
"tags": [
{
"name": "@regression",
"type": "Tag",
"location": {
"line": 1,
"column": 1
}
}
Hi @prashant-ramcharan
Cucumber Project: cucumber.zip
Hi @aravindkesavarapu
This is how Courgette is intended to work.
In the example above, you running using CourgetteRunLevel.SCENARIO
which means Courgette extracts each scenario from the feature file and runs it separately. The end result is you will have each scenario reported separately in the cucumber reports.
Use CourgetteRunLevel.FEATURE
if you need the Cucumber reports to show as one feature result instead of separate scenarios results.
Notice the green tick next to each scenario example. This directly corresponds to the data in cucumber.json
I have integrated courgette-jvm with my project and trying to run the maven command.
It is running good but after running the test cases maven does not recognizing how many test cases it ran, fail, pass. This is running well in my local machine with jenkins getting below error.
java.io.IOException: Cannot run program "java": CreateProcess error=206, The filename or extension is too long at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071) at courgette.runtime.CourgetteFeatureRunner.run(CourgetteFeatureRunner.java:33) at courgette.runtime.CourgetteRunner.runFeature(CourgetteRunner.java:231) at courgette.runtime.CourgetteRunner.lambda$run$3(CourgetteRunner.java:82) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)
finally getting [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.632 s - in a.TestR [INFO] [INFO] Results: [INFO] [INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 29.408 s
pom <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">
Hi @prashant-ramcharan,
I have integrated courgette-jvm with my old project and trying to run the maven command.
It is running good but after running the test cases maven does not recognising how many test cases it ran, fail, pass.
I have attached the screenshot of the maven log & pom.xml.
[ ]
[ ]
`<?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">
`
Please correct me if I have done any wrong thing.
Thanks, Aravind