How to use isReportEnabled method of com.tngtech.jgiven.impl.Config class

Best JGiven code snippet using com.tngtech.jgiven.impl.Config.isReportEnabled

Source:ConfigTest.java Github

copy

Full Screen

...65 }66 @Test67 public void configValuesHaveDefaults() throws Exception {68 Config underTest = createNewTestInstance();69 assertThat(underTest.isReportEnabled()).isTrue();70 assertThat(underTest.getReportDir()).get().extracting(File::getPath).isEqualTo("jgiven-reports");71 assertThat(underTest.textColorEnabled()).extracting(Enum::name).isEqualTo("AUTO");72 assertThat(underTest.filterStackTrace()).isTrue();73 }74 @Test75 public void configFileValuesAreRecognized() throws Exception {76 File reportPath = temporaryFolder.newFolder();77 jgivenConfig.write("jgiven.report.enabled=false\n");78 jgivenConfig.write("jgiven.report.dir="79 + reportPath.getAbsolutePath().replace("\\", "/") + "\n");80 jgivenConfig.write("jgiven.report.text=false\n");81 jgivenConfig.write("jgiven.report.text.color=true\n");82 jgivenConfig.write("jgiven.report.filterStackTrace=false\n");83 Config underTest = createNewTestInstance();84 assertThat(underTest.isReportEnabled()).isFalse();85 assertThat(underTest.getReportDir()).contains(reportPath);86 assertThat(underTest.textReport()).isFalse();87 assertThat(underTest.textColorEnabled()).isEqualTo(ConfigValue.TRUE);88 assertThat(underTest.filterStackTrace()).isFalse();89 }90 @Test91 public void testCommandLinePropertiesTakePrecedenceOverConfigFile() throws Exception {92 jgivenConfig.write("jgiven.report.enabled=false\n");93 setSystemProperty("jgiven.report.enabled", "true");94 Config underTest = createNewTestInstance();95 assertThat(underTest.isReportEnabled()).isTrue();96 }97 @After98 public void cleanupSystemProperties() {99 systemPropertiesBackup.entrySet()100 .stream()101 .peek(entry -> System.clearProperty(entry.getKey()))102 .filter(entry -> entry.getValue() != null)103 .forEach(entry -> System.setProperty(entry.getKey(), entry.getValue()));104 }105 private static Config createNewTestInstance() throws Exception {106 Constructor<Config> constructor = Config.class.getDeclaredConstructor();107 try {108 constructor.setAccessible(true);109 return constructor.newInstance();...

Full Screen

Full Screen

Source:Config.java Github

copy

Full Screen

...40 log.info("Dry Run enabled.");41 }42 }43 static void logReportEnabled() {44 if (!INSTANCE.isReportEnabled()) {45 log.info("Please note that the report generation is turned off.");46 }47 }48 private Config() {49 }50 private static Properties loadConfigFileProperties() {51 String path = System.getProperty(JGIVEN_CONFIG_PATH, "jgiven.properties");52 String charset = System.getProperty(JGIVEN_CONFIG_CHARSET, "UTF-8");53 Properties properties = new Properties();54 try (Reader reader = Files.newBufferedReader(Paths.get(path), Charset.forName(charset))) {55 properties.load(reader);56 } catch (IOException e) {57 log.debug("config file " + path + " not loaded: " + e.getMessage());58 }59 return properties;60 }61 private String resolveProperty(String name) {62 return resolveProperty(name, null);63 }64 private String resolveProperty(String name, String defaultValue) {65 return System.getProperty(name, configFileProperties.getProperty(name, defaultValue));66 }67 /**68 * Returns the directory set either via a configuration file or a system property.69 * If no value is specified and the surefire test classpath is set, the default maven directory will be used,70 * otherwise a default is returned.71 */72 public Optional<File> getReportDir() {73 String reportDirName = resolveProperty(JGIVEN_REPORT_DIR);74 if (reportDirName == null) {75 if (resolveProperty("surefire.test.class.path") != null) {76 reportDirName = "target/jgiven-reports/json";77 log.info(JGIVEN_REPORT_DIR + " not set, but detected surefire plugin, generating reports to "78 + reportDirName);79 } else {80 reportDirName = "jgiven-reports";81 log.debug(JGIVEN_REPORT_DIR + " not set, using default value jgiven-reports");82 }83 }84 File reportDir = new File(reportDirName);85 if (reportDir.exists() && !reportDir.isDirectory()) {86 log.warn(reportDirName + " exists but is not a directory. Will not generate JGiven reports.");87 return Optional.empty();88 }89 log.debug("Using folder " + reportDirName + " to store JGiven reports");90 return Optional.of(reportDir);91 }92 public boolean isReportEnabled() {93 return TRUE.equalsIgnoreCase(resolveProperty(JGIVEN_REPORT_ENABLED, TRUE));94 }95 public void setReportEnabled(boolean enabled) {96 System.setProperty(JGIVEN_REPORT_ENABLED, "" + enabled);97 }98 public ConfigValue textColorEnabled() {99 return ConfigValue.fromString(resolveProperty(JGIVEN_REPORT_TEXT_COLOR, AUTO));100 }101 public boolean textReport() {102 return TRUE.equalsIgnoreCase(resolveProperty(JGIVEN_REPORT_TEXT, TRUE));103 }104 public void setTextReport(boolean b) {105 System.setProperty(JGIVEN_REPORT_TEXT, "" + b);106 }...

Full Screen

Full Screen

Source:CommonReportHelper.java Github

copy

Full Screen

...10import java.util.Optional;11public class CommonReportHelper {12 private static final Logger log = LoggerFactory.getLogger( CommonReportHelper.class );13 public void finishReport(ReportModel model ) {14 if( !Config.config().isReportEnabled() ) {15 return;16 }17 if( model == null || model.getScenarios().isEmpty() ) {18 return;19 }20 new CaseArgumentAnalyser().analyze( model );21 if( Config.config().textReport() ) {22 new PlainTextReporter().write( model ).flush();23 }24 Optional<File> optionalReportDir = Config.config().getReportDir();25 if(optionalReportDir.isPresent() ) {26 setupReportWriter(model, optionalReportDir.get());27 }28 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run JGiven automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful