Reputation: 31
Actually I am not familiar with writing Cucumber test case.
I have written a simple test program which does addtion and substraction and shows the result(using ECLIPSE IDE). Written test case is running successfully.
I want to format the output of test case.
Following is the output :
Feature: Calculator
In order to be able to perform the basic calculator functions of adding and subtracting numbers
As a math user
I want to be able to add a number and subtract a number
Scenario: Addition [90m# Calculator.feature:5[0m
[32mGiven [0m[32m[0m[32m[1m20[0m [90m# CalcTest.initialValue(int)[0m
[32mWhen [0m[32mI add [0m[32m[1m5[0m [90m# CalcTest.i_add(int)[0m
[32mThen [0m[32mthe result is "[0m[32m[1mTwenty-Five[0m[32m"[0m [90m# CalcTest.the_result_is(String)[0m
Scenario: Subtraction [90m# Calculator.feature:9[0m
[32mGiven [0m[32m[0m[32m[1m20[0m [90m# CalcTest.initialValue(int)[0m
[32mWhen [0m[32mI subtract [0m[32m[1m5[0m [90m# CalcTest.i_subtract(int)[0m
[32mThen [0m[32mthe result is "[0m[32m[1mFifteen[0m[32m"[0m [90m# CalcTest.the_result_is(String)[0m
2 Scenarios ([32m2 passed[0m)
6 Steps ([32m6 passed[0m)
0m0.081s
In the testrunner file, I have provided following annotations :
format = {"pretty", "html:bin/cucumber-junit/htmloutput","junit:bin/cucumber-junit/Webpage.xml"},
I can see cucumber-junit folder and index.html file in it. So do I need to code something in HTML to format testcase ouput.
Kindly suggest something.
Thanks in advance :) .
Upvotes: 3
Views: 5009
Reputation: 1996
Short Answer: Just add the code ‘monochrome = true‘ in Cucumber Runner class.
Long Answer: Monochrome option can either set as true or false (default value is false). If it is set as true, it means that the console output for the Cucumber test are much more readable. And if it is set as false, then the console output is not as readable as it should be.
Example Below:
@CucumberOptions(features = "classpath:features/functional/",
glue = {"com.jacksparrow.automation.steps_definitions.functional" },
plugin = { "pretty","json:target/cucumber-json/cucumber.json",
"junit:target/cucumber-reports/Cucumber.xml", "html:target/cucumber-reports"},
tags = { "@BAMS_Submitted_State_Guest_User" },
strict = false,
dryRun = false,
monochrome = true)
Upvotes: 1
Reputation: 1
@CucumberOptions(monochrome = true)
This option can either set as true or false. If it is set as true, it means that the console output for the Cucumber test are much more readable. And if it is set as false, then the console output is not as readable as it should be. practice just add the code ‘monochrome = true‘ in TestRunner class:
package cucumberTest;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Feature"
,glue={"stepDefinition"}
,monochrome = false
)
public class TestRunner {
}
Upvotes: 0