Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cucumber Java - JUnit set monochrome over command line

What is the best way to disable color output for my Cucumber JUnit tests when they are run by a build machine?
It is possible to set monochrome = true in the @CucumberOptions annotation. The problem with that is, running the Tests locally should contain Color.

Setting -Dcucumber.options.monochrome=true is not working, for whatever reason.

Is there any way to set/override this from the command line?

like image 806
Marcel Avatar asked Nov 20 '20 08:11

Marcel


People also ask

What is monochrome in Cucumber options?

Monochrome True in CucumberWhen monochrome value set to true, It will make console output for the Cucumber test much more readable and remove any unreadable character. Now compare the output with above output where monochrome value is set to false, no such unreadable characters are included now.

What is CucumberOptions?

What is Cucumber Options? In layman language, @CucumberOptions are like property files or settings for your test. Basically @CucumberOptions enables us to do all the things that we could have done if we have used cucumber command line.

What is @RunWith in Cucumber?

@RunWith annotation tells JUnit that tests should run using Cucumber class present in 'Cucumber.


1 Answers

Found the solution.
As stated here https://cucumber.io/docs/cucumber/api/#list-configuration-options
Providing -Dcucumber.ansi-colors.disabled=true solves the issue.

like image 120
Marcel Avatar answered Sep 21 '22 00:09

Marcel