Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Execute one BDD feature file always first #230

Open
sudheerah opened this issue May 17, 2020 · 11 comments
Open

Execute one BDD feature file always first #230

sudheerah opened this issue May 17, 2020 · 11 comments
Labels

Comments

@sudheerah
Copy link

sudheerah commented May 17, 2020

Hi there,

Just curious whether there is way to run serenity BDD tests (maven project) in a particular order in command line.

e.g. I have three tests (feature1, feature2 and feature3) and I wanted to run those in CLI in blow order

1. Feature2
2. Feature1 and Feature3 (order doesn't matter)

Using below Maven Dep:

<properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <gherkin.version>5.1.0</gherkin.version>
        <cucumber.version>4.7.2</cucumber.version>
    </properties>
<dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>json-path</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>xml-path</artifactId>
            <version>RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20190722</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>${gherkin.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>${cucumber.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
@wakaleo
Copy link
Member

wakaleo commented May 17, 2020

Not easily - that would imply there is a dependency between the features, which is considered a pretty big Cucumber anti-pattern. You could do it with test suites and runners, but it would be very clunky.

@sudheerah
Copy link
Author

sudheerah commented May 17, 2020

@wakaleo Actually I was trying to implement @BeforeAll with junit. to run setup(). But apparently not working as expected. I tried few solutions. Unfortunately nothing with serenity BDD
Solution1
Solution2

@wakaleo
Copy link
Member

wakaleo commented May 17, 2020

Why not just use Cucumber hooks?

@sudheerah
Copy link
Author

sudheerah commented May 17, 2020

Is there any sample solution you know. I was under impression it is not yet supported. What I read was all these hooks use for within feature files NOT for initial setup before start the suite.

@wakaleo
Copy link
Member

wakaleo commented May 17, 2020

@sudheerah
Copy link
Author

sudheerah commented May 17, 2020

Not supported global hooks which I am after

Global hooks

Cucumber-JVM does not support global hooks.

@wakaleo
Copy link
Member

wakaleo commented May 17, 2020

What problem are you trying to sovle?

@sudheerah
Copy link
Author

Need to load my all the mocks before test execution

@wakaleo
Copy link
Member

wakaleo commented May 17, 2020

I would use @before hooks and a ThreadLocal object.

@sudheerah
Copy link
Author

If you can send me an example will be much appreciated.

@arunahk
Copy link

arunahk commented Jun 26, 2020

@sudheerah use TestNG as runner and use @BeforeSuite?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants