Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue May 16, 2024 · 19 comments Β· Fixed by #2884

Comments

@elbaih101
Copy link

elbaih101 commented May 16, 2024

πŸ‘“ 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>
@davidjgoss davidjgoss transferred this issue from cucumber/cucumber-js May 16, 2024
@mpkorstanje
Copy link
Contributor

How are you selecting the rule?

@elbaih101
Copy link
Author

image
image
iam clicking on the run icon

@elbaih101
Copy link
Author

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
Copy link
Author

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

@elbaih101
Copy link
Author

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

@mpkorstanje
Copy link
Contributor

mpkorstanje commented May 16, 2024

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. πŸ˜†

@elbaih101
Copy link
Author

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

@mpkorstanje
Copy link
Contributor

mpkorstanje commented May 17, 2024

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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

@elbaih101
Copy link
Author

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
Copy link
Contributor

mpkorstanje commented Aug 2, 2024

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
Copy link
Contributor

mpkorstanje commented Aug 2, 2024

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
Copy link
Author

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
Copy link
Author

thanks for your effort

@mpkorstanje
Copy link
Contributor

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.

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

Successfully merging a pull request may close this issue.

2 participants