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

Cannot pass tag expression to maven-surefire-plugin #1596

Closed
mnowotnik opened this issue Apr 2, 2019 · 15 comments
Closed

Cannot pass tag expression to maven-surefire-plugin #1596

mnowotnik opened this issue Apr 2, 2019 · 15 comments
Labels
🙏 help wanted Help wanted - not prioritized by core team ⚡ enhancement Request for new functionality

Comments

@mnowotnik
Copy link

mnowotnik commented Apr 2, 2019

Summary

The new multi-token expression syntax makes it impossible to declare multi token tag expression in the --tags flag inside the -Dcucumber.options flag in maven-surefire-plugin configuration.

Expected Behavior

It should be possible possible to pass multi token tag expression in the -Dcucumber.options flag.

Current Behavior

maven-surefire-plugin crashes throwing either VM crash, IllegalArgumentException or doesn't run any tests depending on the input.

Possible Solution

Make it possible to make single token tag expression without any whitespace characters.

Steps to Reproduce (for bugs)

  1. Create a basic cucumber project using maven with maven-surefire-plugin
  2. In the pom.xml define argLine tag inside maven-surefire-plugin configuration
  3. Inside argLine tag add -Dcucumber.options=" --tags 'not @ignored'" or -Dcucumber.options=' --tags "not @ignored"'
  4. run mvn test

Context & Motivation

My use case is injecting tag expression from parent pom.

Your Environment

  • Version used: 3.0.2
  • Operating System and version: Linux Mint 19
@mnowotnik mnowotnik changed the title Cannot pass tag expression in maven-surefire-plugin Cannot pass tag expression to maven-surefire-plugin Apr 2, 2019
@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 2, 2019

Try:

<argLine>-Dcucumber.options="--tags 'not @ignored'"</argLine>

@mnowotnik
Copy link
Author

I entered that flag slopily in the description.
I have already tried your suggestion, but it doesn't work. If you don't believe me, I can make a minimal example project.

@mpkorstanje
Copy link
Contributor

Please do. I copied that out of an existing project.

@mnowotnik
Copy link
Author

Bad call - I cannot reproduce it in a minimal example. I must a have problem in a configuration then.
Thank you very much.

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Apr 2, 2019

Are you using multiple tags by any chance?

@mnowotnik
Copy link
Author

Just a negation.

@mnowotnik
Copy link
Author

mnowotnik commented Apr 3, 2019

I have tried different configurations using my minimal example and I came to the following conclusion.
Cucumber only works with maven-surefire-plugin version in the range [2.12.2, 2.12.4]. Even the newer versions of cucumber have this implicit requirement. Lower and higher version than in this range causes the maven-surefire-plugin to not read the command line properly or crash with an error: /bin/sh: 1: Syntax error: Unterminated quoted string.

@mnowotnik
Copy link
Author

Differences between versions:
2.11: /opt/java/jdk1.8.0_191/jre/bin/java '-Dcucumber.options=--tags 'not @ignored''
2.12: /opt/java/jdk1.8.0_191/jre/bin/java '-Dcucumber.options=--tags 'not @ignored''
2.12.3: /opt/java/jdk1.8.0_191/jre/bin/java '-Dcucumber.options=--tags '\''not @ignored'\'''
2.13: /opt/java/jdk1.8.0_191/jre/bin/java '-Dcucumber.options=--tags \'not @ignored\''
2.22.4: /opt/java/jdk1.8.0_191/jre/bin/java '-Dcucumber.options=--tags \'not @ignored\''

@mpkorstanje
Copy link
Contributor

You probably have to report this to surefire. The command line is valid.

@mnowotnik
Copy link
Author

mnowotnik commented Apr 3, 2019

I made it work for maven-surefire-plugin:2.22.1 using verbatim command from the 2.12.4 version. If anybody wonders, here's the solution:

<argLine>-Dcucumber.options="--tags '\''not @ignored'\''"</argLine>

I don't think it's possible to use newest maven-surefire-plugin with cucumber currently.

@mpkorstanje mpkorstanje reopened this May 11, 2019
@mpkorstanje
Copy link
Contributor

mpkorstanje commented May 11, 2019

Perhaps we should also consider making tags work without explict @ symbols and/or qoutes. Not sure which symbol is the problem.

@mpkorstanje mpkorstanje added ⚡ enhancement Request for new functionality 🙏 help wanted Help wanted - not prioritized by core team and removed Question labels May 11, 2019
@mpkorstanje
Copy link
Contributor

We can't disambiguate between --tags not @it and --tags not @it path/to/features . So that's already not possible.

@mpkorstanje
Copy link
Contributor

@Mike-now at version 2.22.2 and up this will work:

<argLine>-Dcucumber.options='--tags "not @ignored"'</argLine>

@mpkorstanje
Copy link
Contributor

Looks like this fixed properly in maven-shared-utils/33659 but hasn't made it into the latest Surefire yet. It will be a matter of patience.

mpkorstanje added a commit that referenced this issue Sep 5, 2019
Adds properties for all CLI options. Removes the ability to load rerun files
from the class-path. There appears to be no use case and it significantly
simplifies the implementation.

## Details

Adds:

```
cucumber.ansi-colors.disabled
cucumber.execution.dry-run
cucumber.execution.limit
cucumber.execution.order
cucumber.execution.parallel.config.fixed.parallelism
cucumber.execution.strict
cucumber.execution.wip
cucumber.feature
cucumber.rerun-file
cucumber.filter.name
cucumber.filter.tags
cucumber.glue
cucumber.object-factory
cucumber.plugin
cucumber.snippet-type
```

## Motivation and Context

It is possible to pass properties to cucumber using CLI arguments in a property.
E.g:

```
mvn clean test -Dcucumber.options="--strict --monochrome"
``` 
This is rather complicate, esp when multiple layers are involved and quotes get
confusing (e.x: #1596). 

```
mvn clean test -Dcucumber.options='--strict --monochrome --tags "not @ignored"'
``` 

A better way to do this would be to provide each option individually:

```
mvn clean test -Dcucumber.strict=true -Dcucumber.ansi-colors.disabled=true -Dcucumber.filter.tags="not @ignored"
```

Closes #1675
@lock
Copy link

lock bot commented May 20, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🙏 help wanted Help wanted - not prioritized by core team ⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants