Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98259

Cucumber Runner Class Not Picking Up Tags from Properties File

$
0
0

I am trying to execute my Cucumber runner class by accepting tags from a .properties file. However, it seems that Cucumber is not recognizing the tags, as it ends up running all my tests. Below are the Runner class and ConfigurationReader class that reads values from the .properties file. How can I pass the tags from the file so that they are executed?

Runner Class:

import org.junit.runner.RunWith;import io.cucumber.junit.Cucumber;import io.cucumber.junit.CucumberOptions;import //.ConfigurationReader;@RunWith(Cucumber.class)@CucumberOptions(    features = "src/test/resources/features",    glue = "//my Stepdefenitions",    dryRun = false)public class CukesRunner {    static {        String tags = ConfigurationReader.getTags();        if (tags != null && !tags.isEmpty()) {            System.setProperty("cucumber.filter.tags", tags);        }    }}

ConfigurationReader Class:

import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.Properties;public class ConfigurationReader {    private static Properties properties = new Properties();    static {        loadProperties();    }    private static void loadProperties() {        String configFilePath = System.getProperty("config.file", "configuration.properties");        try (InputStream file = new FileInputStream(configFilePath)) {            properties.load(file);        } catch (IOException e) {            System.out.println("Error occurred while reading configuration file: " + configFilePath);            e.printStackTrace();        }    }    public static String getProperty(String key) {        return properties.getProperty(key);    }    public static String getTags() {        return properties.getProperty("tags", "@test");    }}

Viewing all articles
Browse latest Browse all 98259

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>