cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

running rules from the feature file causes the whole feature file to be run if the rule has no tag on it #2882

Open elbaih101 opened 4 months ago

elbaih101 commented 4 months ago

šŸ‘“ What did you see?

running rules from the feature file causes the whole feature file to be run if the rule has no tag on it

āœ… What did you expect to see?

the rule used to run even if their were no tag on it

šŸ“¦ Which tool/library version are you using?

Java Cucumber 7.17.0

šŸ”¬ How could we reproduce it?

create a feature file containing a rule then try to run the rule

šŸ“š Any additional context?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>Nazeel-Project</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
<!--this dependencies are for cucumber and selenium-->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>7.17.0</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.17.0</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>4.20.0</version>
        </dependency>
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.8.0</version>
        </dependency>
<!--       -->
        <!-- those dependencies for reporting  -->
        <dependency>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>5.8.1</version>
        </dependency>
<!--        json manbulation and extraction-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.17.1</version>
        </dependency>
<!--        Excution and test mangement-->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.2.5</version>
        </dependency>
<!--faker-->
        <dependency>
            <groupId>com.github.javafaker</groupId>
            <artifactId>javafaker</artifactId>
            <version>1.0.2</version>
        </dependency>

<!--      logging-->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.13</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <!--Using this plug in to contorol the excution of the runners classes-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.5</version>
                <configuration>
                    <!-- those two following sections control the parralel excution-->
                    <parallel>classes</parallel>
                    <threadCount>4</threadCount>
                    <testFailureIgnore>true</testFailureIgnore>
                    <runOrder>Alphabetical</runOrder>
<!-- this section defines the runners Classes  Literals to run them as the main functions-->
                    <includes>
                        <include>**/*Runners.java</include> <!-- this should be the name of your runner class -->
                    </includes>
                </configuration>
                <!-- this excution so that only the tesets are run during test phase-->
                <executions>
                    <execution>
                        <id>surefire-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!--reporting  -->
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>5.8.1</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>test</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>Nazeel-Project</projectName>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <inputDirectory>${project.build.directory}</inputDirectory>
                            <jsonFiles>
                                <param>**/cucumber*.json</param>
                            </jsonFiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
mpkorstanje commented 4 months ago

How are you selecting the rule?

elbaih101 commented 4 months ago

image image iam clicking on the run icon

elbaih101 commented 4 months ago

thats wehn i click on it without any tags image

and thats with tag image

but it doesnt run

image no steps are run at all

elbaih101 commented 4 months ago

IF i run it through the runners class it runs no proplem but this makes depugging hard for me

elbaih101 commented 4 months ago

thanks is there anything Iam supposed to do now or just wait

mpkorstanje commented 4 months ago

The problem is a bit complicated.

The third one will be fixed by https://github.com/cucumber/cucumber-jvm/pull/2884. And once released, IDEA will have to fix this the first two one their end. I'll create the feature request for that, because I also want them to make it possible to select examples.

edit:

Once created, I suppose you could upvote the request, and get other people to upvote it too. JetBrains isn't very quick with feature requests otherwise. :laughing:

elbaih101 commented 4 months ago

The problem is a bit complicated.

  • IDEA selects the whole feature to run when targeting a rule.
  • IDEA uses the --name filter when targeting a rule with an annotation.
  • Cucumber does not support selecting rules (or examples) by line number.

The third one will be fixed by #2884. And once released, IDEA will have to fix this the first two one their end. I'll create the feature request for that, because I also want them to make it possible to select examples.

edit:

Once created, I suppose you could upvote the request, and get other people to upvote it too. JetBrains isn't very quick with feature requests otherwise. šŸ˜†

of course iam willing to do this once u create it

elbaih101 commented 4 months ago

i think i created one https://youtrack.jetbrains.com/issue/IDEA-353626/running-rules-from-the-feature-file-causes-the-whole-feature-file-to-be-run-if-the-rule-has-no-tag-on-it

mpkorstanje commented 4 months ago

I think that won't be very helpful, you've left out the information needed for Intelij to fix the issue. And without the fix being released in Cucumber, they won't be able to implement anything just yet.

elbaih101 commented 4 months ago

I think that won't be very helpful, you've left out the information needed for Intelij to fix the issue. And without the fix being released in Cucumber, they won't be able to implement anything just yet.

sorry i will close it then wait for u iam being Impatient

elbaih101 commented 4 months ago

I think that won't be very helpful, you've left out the information needed for Intelij to fix the issue. And without the fix being released in Cucumber, they won't be able to implement anything just yet.

sorry i will close it then wait for u iam being Impatient

seems i cant delete it sorry for the inconvenience

mpkorstanje commented 4 months ago

No worries.

How did you get these markers from your screenshot?

Screenshot from 2024-05-17 18-01-26

I don't get these. I only get them for Features, Rules, Scenarios and Scenario Outlines.

elbaih101 commented 4 months ago

I am using cucumber + plugin but it's not perfect

elbaih101 commented 2 months ago

is there any update on the ticket u said will submit for JetBrains Sorry for the comment after so long but i just wanted to check

mpkorstanje commented 2 months ago

So I made https://youtrack.jetbrains.com/issue/IDEA-353691 and that's where we are at right now.

The problem is a bit more complicated than I thought. For IDEA it is important that their selections are stable, which line numbers aren't. So while selecting by line number works well for rerunning failed scenarios, it not great when users may change the file and the line numbers.

I have thought about extending --name to match against scenario and example names, but I'm a little weary here. The option takes a regular expression as an argument, and extending what the expression might would be a breaking change. Which means it would have to be delayed for the next major version.

And for the next major version I would like to standardize on the JUnit Platform. Which would allow IDEA to select rules, scenarios and examples programmatically making the whole problem moot. But that is a long way of and gated behind a few other big projects.

mpkorstanje commented 2 months ago

That said, if you are really interested in this feature you could look into expanding the NamePredicate to work like the LinePredicate. If gated behind a feature toggle I reckon we can avoid unwanted breaking changes. I would be happy to accept a pull request for that.

Personally, I don't think it is worth the effort thought. IDEA seems to be extremely slow to respond to issues, so it is unlikely they'll ever use --name with a rule name.

elbaih101 commented 2 months ago

That said, if you are really interested in this feature you could look into expanding the NamePredicate to work like the LinePredicate. If gated behind a feature toggle I reckon we can avoid unwanted breaking changes. I would be happy to accept a pull request for that.

Personally, I don't think it is worth the effort thought. IDEA seems to be extremely slow to respond to issues, so it is unlikely they'll ever use --name with a rule name.

i don't think i have the knowledge or the skills to do so perhaps i will wait

elbaih101 commented 2 months ago

thanks for your effort

mpkorstanje commented 1 month ago

i don't think i have the knowledge or the skills to do so perhaps i will wait

If you want to try, I'm happy to give you some pointers when you get stuck. Hop on the discord.