Cucumber for the JVM

Overview

Cucumber JVM

OpenCollective OpenCollective

Maven Central Build Status Coverage Status

Cucumber-JVM is a pure Java implementation of Cucumber. You can run it with the tool of your choice.

Cucumber-JVM also integrates with all the popular Dependency Injection containers.

Getting started

Questions, Problems, Help needed?

Please ask on

Bugs and Feature requests

You can register bugs and feature requests in the Github Issue Tracker.

Please bear in mind that this project is almost entirely developed by volunteers. If you do not provide the implementation yourself (or pay someone to do it for you), the bug might never get fixed. If it is a serious bug, other people than you might care enough to provide a fix.

Contributing

If you'd like to contribute to the documentation, checkout cucumber/docs.cucumber.io otherwise see our CONTRIBUTING.md.

Issues
  • Add @BeforeAll and @AfterAll hooks

    Add @BeforeAll and @AfterAll hooks

    People keep asking for BeforeAll and AfterAll hooks. I haven't had a big need for them myself, but it seems to me this would be sufficient:

    public class GlobalHooks {
        private static boolean dunit = false;
    
        @Before
        public void beforeAll() {
            if(!dunit) {
                Runtime.getRuntime().addShutdownHook(afterAllThread);
                // do the beforeAll stuff...
                dunit = true;
            }
        }
    }
    

    If this doesn't cut it for you, please explain in this ticket, and maybe we'll add special support for it.

    :safety_pin: pinned :dollar: bounty $1000 :cucumber: core team 
    opened by aslakhellesoy 128
  • [Core] Parallel cukes

    [Core] Parallel cukes

    Notice

    This PR replaces Parallel support #1357 and relies on Refactor Runtime #1367

    Outline

    I’ve previously used another implementation to deliver parallel execution of cucumber tests, however it basically wrapped up the creation and execution of Runtime’s, followed by the need to merge the multiple JSON/HTML etc reports that followed.

    I reviewed the current implementation and also took note of comments in Support concurrent executions of scenarios also I perused all tickets related to running in parallel cukes for other insights

    Main changes

    Added --threads argument to runtime options

    Allows users to specify the (max) number of threads to be used to run the tests

    The actual number of threads used will be the smaller of the given --threads value and the number of features to be executed

    Tests are placed into a Queue and consumed by each thread when needed, resulting in a more performant usage of the threads & less deterministic order of Features being run

    New formatter introduced TimelineFormatter

    Which produces reports using vsjis.org timeline to highlight which feature was run on which Thread and when.
    Note: the resources (js, html etc) are currently within cucumber-core if the PR is accepted then I’d imagine these would have to be moved out into its own project, similarly to cucumber-html. timelineformatter example.zip

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue).
    • [x] New feature (non-breaking change which adds functionality).
    • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected). ~~- Runtime constructor now private Runtime.Builder introduce to hide away boiler plate setup/instantiation code~~

    Checklist:

    • [x] I've added tests for my code.
    • [x] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    opened by boaty82 65
  • cucumber-java8 fails on OpenJDK 1.8.0

    cucumber-java8 fails on OpenJDK 1.8.0

    Cucumber-Java8 depends on internals of the implementation of Oracle's JDK8. When I started experimenting with it I just always got the following exception:

    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.056 sec <<< FAILURE! - in soy.wimmer.CucumberIT
    Feature: Cucumber with Java8  Time elapsed: 0.047 sec  <<< ERROR!            
    cucumber.runtime.CucumberException: Failed to instantiate class soy.wimmer.CucumberStepdefs
    […]                                                                          
    Caused by: java.lang.reflect.InvocationTargetException: null                 
    […]                                                                          
    Caused by: cucumber.runtime.CucumberException: java.lang.IllegalArgumentException: Wrong type at constant pool index
    […]                                                                          
    Caused by: java.lang.IllegalArgumentException: Wrong type at constant pool index
        at sun.reflect.ConstantPool.getMemberRefInfoAt0(Native Method)           
        at sun.reflect.ConstantPool.getMemberRefInfoAt(ConstantPool.java:47)     
        at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getTypeString(ConstantPoolTypeIntrospector.java:37)
        at cucumber.runtime.java8.ConstantPoolTypeIntrospector.getGenericTypes(ConstantPoolTypeIntrospector.java:27)
        at cucumber.runtime.java.Java8StepDefinition.<init>(Java8StepDefinition.java:45)
        at cucumber.runtime.java.JavaBackend.addStepDefinition(JavaBackend.java:162)
        at cucumber.api.java8.En.Given(En.java:190)                              
        at soy.wimmer.CucumberStepdefs.<init>(CucumberStepdefs.java:8)           
    […]
    

    The test project causing this output is available at https://github.com/mawis/cucumber-java8-test

    While it fails on OpenJDK8 it works without problems on Oracle JDK8. I consider this to be a bug, as I don't think that cucumber should depend on a specific implementation of the compiler.

    opened by mawis 63
  • [Core] Implement cucumber expressions

    [Core] Implement cucumber expressions

    Summary

    • Implements Cucumber expressions
    • Removes XStream
    • Adds DataTables from https://github.com/cucumber/cucumber/pull/291
    • Introduces the concept of StepExpressions which combines a CucumberExpression and DataTable expression. Currently data table expressions are limited to a name or java type. Currently only the implicit type derived from the method argument is used.

    For a working example check the calculator examples.

    How to build

    Install (mvn install) datatables/java from cucumber/cucumber Then install this branch. If it fails you may need to remove pax-exam from examples/pom,xml. This is okay.

    Todo

    • [x] Fix android examples ~~* [ ] Add link to configuration docs in exceptions~~
    • [x] Test SnippetGenerators and StepdefGenerator icm Idea ~~* [ ] Update documentation~~
    • [x] Write blog post ~~* [ ] File IDEA bug about "Pattern expected" warning~~
    • [x] Undefined parameter type error should be similarly friendly as missing table type

    This closes #1041

    opened by mpkorstanje 63
  • [Core] Add Before and AfterStep hooks

    [Core] Add Before and AfterStep hooks

    This PR adds a new feature of AfterStep. Methods annotated with AfterStep will be executed after every step. For HTML Reports to work properly after this change , this PR requires to be merged

    Motivation and Context

    This change was requested by users of cucumber-jvm

    Types of changes

    • [ ] Bug fix (non-breaking change which fixes an issue).
    • [x] New feature (non-breaking change which adds functionality).
    • [x] Breaking change (fix or feature that would cause existing functionality to not work as expected).

    Checklist:

    • [x] I've added tests for my code.
    • [x] My change requires a change to the documentation.
    • [ ] I have updated the documentation accordingly.
    opened by coding-yogi 53
  • International keywords

    International keywords

    Hi,

    I have problems switching the examples to Swedish international keywords. I've tried helloworld as well as java-calculator and both are having problems when I change to the following import statements:

    import cucumber.api.java.sv.Så; import cucumber.api.java.sv.När;

    It seems that Eclipse is not recognizing these packages in the repositories. I'm using everything else "as-is" from github (cucumber-jvm 1.1.3).

    Please note that I have no problems with:

    import cucumber.api.java.sv.Givet;

    which makes me suspect something related to the special Swedish characters.

    opened by hangvar 51
  • Support step hooks

    Support step hooks

    Feature: https://github.com/cucumber/cucumber/wiki/Hooks

    I am surprised that cucumber-jvm does not support step hooks. For example, when I use cucumber-jvm to build web application acceptance tests, I'd like to take screenshot after each step. Without step hooks, I have to invoke the method in every single step. painful.

    Any reason don't include this feature?

    :zap: enhancement :hourglass: stale 
    opened by ShijunK 44
  • Add command line option support for Android

    Add command line option support for Android

    This will enable cucumber-android test projects that are started through the activity manager (adb shell am instrument) to receive additional Cucumber options from the command line.

    General A normal test project would be started like this:

    adb shell am instrument -w com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
    

    The activity manager (am) supports additional extras for the instrument command:

    adb shell am instrument -w -e key value com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
    

    Multiple extras can be passed like this: -e key1 value1 -e key2 value2

    Supported Cucumber options

    am instrument argumentCucumber option
    -e glue PATH--glue PATH
    -e format FORMAT[:PATH_OR_URL]--format FORMAT[:PATH_OR_URL]
    -e tags TAG_EXPRESSION--tags TAG_EXPRESSION
    -e name REGEXP--name REGEXP
    -e dryRun true
    -e noDryRun true
    --[no-]-dry-run
    -e monochrome true
    -e noMonochrome true
    --[no-]-monochrome
    -e strict true
    -e noStrict true
    --[no-]-strict
    -e snippets [underscore|camelcase]--snippets [underscore|camelcase]
    -e dotcucumber PATH_OR_URL--dotcucumber PATH_OR_URL
    -e features [ [FILE|DIR][:LINE[:LINE]*] ]+[ [FILE|DIR][:LINE[:LINE]*] ]+

    Single argument for Cucumber options A single argument extra for the Cucumber options is also supported:

    adb shell am instrument -w -e cucumberOptions "--dry-run --name 'My Test'" com.mypackage.app.test/cucumber.api.android.CucumberInstrumentation
    

    When using cucumberOptions all other Cucumber option extras will be ignored.

    A few things to note

    • You cannot pass just a key without a value, that means a boolean option such as --strict would have to be passed like this: -e strict true
    • Feature references can be passed: -e features [ [FILE|DIR][:LINE[:LINE]*] ]+
    • Values containing spaces need to be passed like this: -e name "'My Feature'"
    • It is not possible to pass the same key multiple times, e. g. -e name Feature1 -e name Feature2 would result in the first name argument being overwritten by the second name argument: The test app would only see Feature2. In order to pass options more than once, you would need to separate the values by two dashes --, like this: -e name Feature1--Feature2

    This pull request also adds support for the following legacy test runner arguments

    am instrument argumentDescription
    -e count trueCount the number of tests (scenarios)
    -e debug trueWait for a debugger to attach before starting to execute the tests.
    Note: This was added by PR #613 already.
    -e log trueEnable Cucumber dry-run (same as --e dryRun true)
    -e coverage trueEnable EMMA code coverage
    -e coverageFile "/path/coverage.ec"Set the file name and path of the EMMA coverage report

    Asking for comments from the community, especially on the selection of the option value separator. I don't particularly like the two dashes, but it works. Does anyone have a better suggestion?

    The requirements are simple: It has to be a character or separator that is

    1. command line compatible (that means & and | will not work)
    2. not already used by Cucumber (e. g. , as in --tags @tag1,@tag2
    3. unlikely to appear in any feature name, file/path/url name, or tag name

    Thanks

    opened by friederbluemle 44
  • Add JUnit 5 Support

    Add JUnit 5 Support

    Summary

    Provide a JUnit 5 extension for cucumber.

    Expected Behavior

    When writing a test with JUnit 5 in our environment, we need to replicate a base environment in a way that we use different Extensions in order to to run tests. So we like to have a Scenario something like this:

    @ExtendWith(CucumberExtension.class)
    @ExtendWith(MockitoExtension.class)
    @ExtendWith(BaseBusinessEnvironmentExtension.class)
    class MyBusinessTest {
       @BeforeEach
        void init(@Mock Person person) {
            when(person.getName()).thenReturn("Dilbert");
        }
    
        @Test
        void simpleTestWithInjectedMock(@Mock Person person) {
            assertEquals("Dilbert", person.getName());
        }
    }
    

    Current Behavior

    At the moment under JUnit 4 we needed to tweak the Cucumber runner in order to call default JUnit 4 annotations.

    Possible Solution

    We like to help create an CucumberExtension that handles the Cucumber specific annotations for JUnit 5 as an JUnit 5 extension, so that it can be combined with other extensions as for example mocking frameworks.

    :zap: enhancement :safety_pin: pinned 
    opened by reinhapa 42
  • Support concurrent executions of scenarios

    Support concurrent executions of scenarios

    Currently it's only possible to execute feature classes in parallel. In case you have independent scenarios (and you really should) it would be nice to run them concurrently. The current codebase does not support this. First of all the reporting is inherently sequential and there is some state in the Runtime class (skipNextStep and scenarioResult). I would be happily contributing a patch, but this would require a major change of some of the internal structure.

    opened by whiskeysierra 37
  • [Kotlin] @BeforeAll and @AfterAll throws exceptions when used in kotlin

    [Kotlin] @BeforeAll and @AfterAll throws exceptions when used in kotlin

    Describe the bug @BeforeAll and @AfterAll throws exceptions when used in kotlin

    To Reproduce

    class MyStepDefinitions  {
    
        companion object {
    
            @JvmStatic
            @BeforeAll
            fun beforeAll() {
                println("before all")
            }
    
            @JvmStatic
            @AfterAll
            fun afterAll() {
                println("after all")
            }
        }
    
        //some steps declaration
    

    Throws exception:

    
    Before All/After All failed
    io.cucumber.core.exception.CompositeCucumberException: There were 2 exceptions. The details are in the stacktrace below.
    	at io.cucumber.core.runtime.RethrowingThrowableCollector.getThrowable(RethrowingThrowableCollector.java:57)
    	at io.cucumber.core.runtime.CucumberExecutionContext.getThrowable(CucumberExecutionContext.java:81)
    	at io.cucumber.core.runtime.CucumberExecutionContext.finishTestRun(CucumberExecutionContext.java:76)
    	at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
    	at io.cucumber.core.runtime.Runtime.run(Runtime.java:85)
    	at io.cucumber.core.cli.Main.run(Main.java:87)
    	at io.cucumber.core.cli.Main.main(Main.java:30)
    	Suppressed: io.cucumber.java.InvalidMethodSignatureException: A method annotated with BeforeAll or AfterAll must have one of these signatures:
     * public static void before_or_after_all()
    at void com.lohika.cucumber.MyStepDefinitionsMethod$Companion.beforeAll()
    
    
    		at io.cucumber.java.InvalidMethodSignatureException$InvalidMethodSignatureExceptionBuilder.build(InvalidMethodSignatureException.java:52)
    		at io.cucumber.java.JavaStaticHookDefinition.createInvalidSignatureException(JavaStaticHookDefinition.java:44)
    		at io.cucumber.java.JavaStaticHookDefinition.requireValidMethod(JavaStaticHookDefinition.java:28)
    		at io.cucumber.java.JavaStaticHookDefinition.<init>(JavaStaticHookDefinition.java:17)
    		at io.cucumber.java.GlueAdaptor.addDefinition(GlueAdaptor.java:30)
    		at io.cucumber.java.JavaBackend.lambda$loadGlue$1(JavaBackend.java:42)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:67)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:58)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:33)
    		at io.cucumber.java.JavaBackend.lambda$loadGlue$2(JavaBackend.java:40)
    		at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    		at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    		at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    		at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
    		at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    		at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    		at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    		at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    		at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    		at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    		at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    		at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    		at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    		at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    		at io.cucumber.java.JavaBackend.loadGlue(JavaBackend.java:40)
    		at io.cucumber.core.runner.Runner.<init>(Runner.java:56)
    		at io.cucumber.core.runtime.SingletonRunnerSupplier.createRunner(SingletonRunnerSupplier.java:44)
    		at io.cucumber.core.runtime.SingletonRunnerSupplier.get(SingletonRunnerSupplier.java:35)
    		at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:35)
    		at io.cucumber.core.runtime.CucumberExecutionContext.getRunner(CucumberExecutionContext.java:114)
    		at io.cucumber.core.runtime.CucumberExecutionContext.runBeforeAllHooks(CucumberExecutionContext.java:65)
    		at io.cucumber.core.runtime.Runtime.lambda$run$0(Runtime.java:81)
    		at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
    		at io.cucumber.core.runtime.Runtime.run(Runtime.java:80)
    		... 2 more
    	Suppressed: io.cucumber.java.InvalidMethodSignatureException: A method annotated with BeforeAll or AfterAll must have one of these signatures:
     * public static void before_or_after_all()
    at void com.lohika.cucumber.MyStepDefinitionsMethod$Companion.beforeAll()
    
    
    		at io.cucumber.java.InvalidMethodSignatureException$InvalidMethodSignatureExceptionBuilder.build(InvalidMethodSignatureException.java:52)
    		at io.cucumber.java.JavaStaticHookDefinition.createInvalidSignatureException(JavaStaticHookDefinition.java:44)
    		at io.cucumber.java.JavaStaticHookDefinition.requireValidMethod(JavaStaticHookDefinition.java:28)
    		at io.cucumber.java.JavaStaticHookDefinition.<init>(JavaStaticHookDefinition.java:17)
    		at io.cucumber.java.GlueAdaptor.addDefinition(GlueAdaptor.java:30)
    		at io.cucumber.java.JavaBackend.lambda$loadGlue$1(JavaBackend.java:42)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:67)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:58)
    		at io.cucumber.java.MethodScanner.scan(MethodScanner.java:33)
    		at io.cucumber.java.JavaBackend.lambda$loadGlue$2(JavaBackend.java:40)
    		at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
    		at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    		at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
    		at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
    		at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    		at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    		at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
    		at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
    		at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
    		at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    		at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
    		at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
    		at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    		at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
    		at io.cucumber.java.JavaBackend.loadGlue(JavaBackend.java:40)
    		at io.cucumber.core.runner.Runner.<init>(Runner.java:56)
    		at io.cucumber.core.runtime.SingletonRunnerSupplier.createRunner(SingletonRunnerSupplier.java:44)
    		at io.cucumber.core.runtime.SingletonRunnerSupplier.get(SingletonRunnerSupplier.java:35)
    		at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:35)
    		at io.cucumber.core.runtime.CucumberExecutionContext.getRunner(CucumberExecutionContext.java:114)
    		at io.cucumber.core.runtime.CucumberExecutionContext.runAfterAllHooks(CucumberExecutionContext.java:70)
    		at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
    		at io.cucumber.core.runtime.Runtime.run(Runtime.java:84)
    		... 2 more
    

    Your Environment

    • Versions used 7.1.0
    opened by ocherniavskyi-lohika-tix 1
  • Support multiple DocStringTypes with the same contentType (#2343)

    Support multiple DocStringTypes with the same contentType (#2343)

    Is your pull request related to a problem? Please describe. It's the implementation to: https://github.com/cucumber/cucumber-jvm/issues/2343

    Describe the solution you have implemented With this implementation is now possible to have DocStrings of default type ("") or a particular contentType like "application/json" to have multiple DocStringTypes (different return types). This gives leverage for users to take full advantage of Jackson ObjectMapper conversions. Tests were implemented and updated to cover the new situations where it should be allowed to have multiple DocStringTypes per same contentType, this creates much more concise transformers but doesn't allow any more ambiguity around Object as a return type.

    opened by PostelnicuGeorge 7
  • [Java] Define step definitions and hooks with minimal ceremony

    [Java] Define step definitions and hooks with minimal ceremony

    Is your pull request related to a problem? Please describe.

    [Java] Allow non-private classes to contain hooks and allow hook annotations in non-public methods (#2370)

    Describe the solution you have implemented

    1. When scanning methods of a class, allow the class to have package-private and protected visibility in addition to the previously allowed public visibility.
    2. When scanning methods of a class, allow the hook-annotated methods to have package-private and protected visibility in addition to the previously allowed public visibility.

    Additional context None.

    opened by rozenshteyn 2
  • Document how to publish reports with the JUnit 5 runner.

    Document how to publish reports with the JUnit 5 runner.

    Many users discover Cucumber Reports by reading the banner printed at the end of the run:

    ┌───────────────────────────────────────────────────────────────────────────────────┐
    │ Share your Cucumber Report with your team at https://reports.cucumber.io          │
    │ Activate publishing with one of the following:                                    │
    │                                                                                   │
    │ src/test/resources/cucumber.properties:          cucumber.publish.enabled=true    │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.enabled=true    │
    │ Environment variable:                            CUCUMBER_PUBLISH_ENABLED=true    │
    │ JUnit:                                           @CucumberOptions(publish = true) │
    │                                                                                   │
    │ More information at https://cucumber.io/docs/cucumber/environment-variables/      │
    │                                                                                   │
    │ Disable this message with one of the following:                                   │
    │                                                                                   │
    │ src/test/resources/cucumber.properties:          cucumber.publish.quiet=true      │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.quiet=true      │
    └───────────────────────────────────────────────────────────────────────────────────┘
    

    The instructions suggest that one way to enable publishing is to add cucumber.publish.enabled=true to src/test/resources/junit-platform.properties. However, it isn't obvious that defining the environment variable will have no effect with JUnit 5.

    This might come as a surprise to users who are upgrading from v6 to v7 and trying out the new JUnit 5 runner.

    I propose that we modify the banner to make it more explicit what activation mechanism work with what runners:

    ┌───────────────────────────────────────────────────────────────────────────────────┐
    │ Share your Cucumber Report with your team at https://reports.cucumber.io          │
    │ Activate publishing with one of the following:                                    │
    │                                                                                   │
    │ JUnit 5:                                                                          │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.enabled=true    │
    │ JUnit 4 / TestNG:                                                                 │
    │ src/test/resources/cucumber.properties:          cucumber.publish.enabled=true    │
    │ Environment variable:                            CUCUMBER_PUBLISH_ENABLED=true    │
    │                                                                                   │
    │ More information at https://cucumber.io/docs/cucumber/environment-variables/      │
    │                                                                                   │
    │ Disable this message with one of the following:                                   │
    │                                                                                   │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.quiet=true      │
    │ src/test/resources/cucumber.properties:          cucumber.publish.quiet=true      │
    └───────────────────────────────────────────────────────────────────────────────────┘
    

    One more thing - when people have published their first report, they are encouraged to sign in and create a token, and to use this token to publish reports. The Cucumber Reports web site instructs users to do this by defining CUCUMBER_PUBLISH_TOKEN=...... before running Cucumber.

    However, as with CUCUMBER_PUBLISH_ENABLED - this has no effect on the JUnit 5 runner. It is possible to activate publishing with a token by adding cucumber.publish.token=..... to src/test/resources/junit-platform.properties, but this is obviously insecure, as the token would typically end up in source control this way.

    From what I can tell, the only way to enable publishing with CUCUMBER_PUBLISH_TOKEN is to lean on features offered by the build tool. With Maven, it can be done as shown in https://github.com/cucumber/cucumber-java-skeleton/pull/70.

    We need to figure out a way to make this process more discoverable for users. Any suggestions?

    :book: documentation 
    opened by aslakhellesoy 6
  • Update codecov

    Update codecov

    The build pipeline reports coverage through codecov. We are currently using v1 and should upgrade to v2 as the former is being deprecated and will receive rolling brown outs.

    • https://about.codecov.io/blog/introducing-codecovs-new-uploader/
    • https://github.com/cucumber/cucumber-jvm/blob/main/.github/workflows/build.yml#L58-L81
    • https://github.com/codecov/codecov-action#migration-from-v1-to-v2
    :pray: help wanted good first issue :wrench: build 
    opened by mpkorstanje 0
  • Weld Initiator support with Junit in Cucumber

    Weld Initiator support with Junit in Cucumber

    I was writing some component tests for a project using Junit and Weld Junit containers. Now I am trying to convert them into feature acceptance tests using Cucumber.

    As I can see Cucumber uses CDI2 a maven dependency where a non-customizable weld se container is started and enables dependency injection. This has some serious limitations , the biggest is that it reads from the main/beans.xml file and not from the test/beans xml.

    It would be really amazing if Cucumber could have a customizable CDI container injection.

    https://github.com/weld/weld-junit <- Source.

    Example.

    WeldInitiator weld = WeldInitiator.from(WeldInitiator.createWeld().enableDiscovery().addExtensions(ConfigExtension.class) .property("org.jboss.weld.se.archive.isolation", "false") ).activate(RequestScoped.class, ApplicationScoped.class) .inject(this) .setPersistenceContextFactory(SomePersistence) .setEjbFactory(someFactory) .setPersistenceUnitFactory(someUnit) .build();

    I manage to get it work as a Classrule with junit 4 and cucumber but has some problems and limitations.

    @RunWith(Cucumber.class)
    @CucumberOptions(features = "src/test/resources/cwm/something/adapter/foo")
    public class RunCucumberTestIT {
        
        @ClassRule
        public static WeldInitiator weld = WeldInitiator.from(WeldInitiator.createWeld().enableDiscovery().addExtensions(ConfigExtension.class)
                                                                           .addBeanClass(someBeanClass.class)
                                                                           .property("org.jboss.weld.se.archive.isolation", "false")
        ).activate(RequestScoped.class, ApplicationScoped.class)
                                                        .inject(this)
                                                        .setPersistenceContextFactory(SomePersistence)
                                                        .setEjbFactory(someFactory)
                                                        .setPersistenceUnitFactory(someUnit)
                                                        .build();
    
    }
    

    Also with the new BeforeAll & AfterAll hooks i can use TestContainers with cucumber, this approach could really be an alternative to Arquillian and cukespace.

    opened by iliadelo 0
  • Expose report dialog for reusage during CI

    Expose report dialog for reusage during CI

    Is your feature request related to a problem? Please describe.

    I am using a dockerized image running Cucumber through io.cucumber.core.cli.Main#main. I run this dockerized image in a CI in order to run NRT on PR. I am getting good result and steps are working as expected.

    But, I am unable to catch the:

    ┌──────────────────────────────────────────────────────────────────────────┐
    │ View your Cucumber Report at:                                            │
    │ https://reports.cucumber.io/reports/b2eb92c3-fca3-4cde-af5f-d2a3f98b2d2e │
    │                                                                          │
    │ This report will self-destruct in 24h.                                   │
    │ Keep reports forever: https://reports.cucumber.io/profile                │
    └──────────────────────────────────────────────────────────────────────────┘
    

    hence unable to extract it in order to send it to any kind of hook.

    Describe the solution you'd like

    In my specific case, since I am using GitHub Actions, I would love to be able to either:

    • provide some kind of --ci=github-actions which would either:
      • prepend the famous --set-output in order to use the result later on
      • set an environment variable in order to use the result later on
    • allow overriding of MessageFormatter to enable more customization

    Describe alternatives you've considered

    I do not know much about GitHub Actions and CI in general, so I would love to hear your alternatives :roll_eyes:

    Additional context

    Interacting with Cucumber message API

    I tried to:

    • mount a volume on /tmp to fetch the cucumber report
    • GET https://messages.cucumber.io/api/reports and get the Location header
    • PUT the cucumber report found in /tmp against that location header

    Redirecting output to a file to interact with it

    One could also redirect output (which seems to be stderr by the way) of the Docker container to a file, and get the report comment by doing some kind of scripting:

    grep -B2 -A5 'https://reports.cucumber.io/reports' ${DOCKER_CONTAINER_LOG_FILE} | tail -8
    

    and the reuse that content.

    Both feels a bit of a hack and I have the feeling that is not what you expect us to do.

    :zap: enhancement 
    opened by hypr2771 1
  • hooks should not require public visibility -- at least should log an error/warning

    hooks should not require public visibility -- at least should log an error/warning

    Is your feature request related to a problem? Please describe. I was frustrated when i tried to figure out why my tests would fail. Until i notices that my setup was not public. From the old days in junit i know that they used to require that too, but no more and nowadays it's so common to have all that test stuff with package visibility (to avoid cluttering autocompletion in IDEs i guess) I just did it here too w/o even giving it a 2nd though.

    So now my code looks like so to make my team mates (we are all new CC) aware of the fact.

       @Before //method must be public!! otherwise it's silently ignored!
        public void setUp() {
            msUniteTestHarness.reset();
        }
    

    Describe the solution you'd like Also allow package visibility but by all means don't just silently drop the execution

    Describe alternatives you've considered Throwing an error would be OK too but behavior is not anymore in alignment with junit.

    :zap: enhancement :pray: help wanted 
    opened by elonderin 14
  • Support multiple DocStringTypes with the same contentType

    Support multiple DocStringTypes with the same contentType

    As far as documentation goes, the fact that jackson json library is used and DataTableType can have multiple return types, it's not that obvious why DocStringType has only 1 return type for all feature files/project?

    Given the following example:
      Scenario: Test whether DocStringType allows conversion of 2 different types of records
        Given I have the following cars
        """json
        [
        {
        "name": "Murcielago",
        "brand": "Lamborghini"
        },
        {
        "name": "Sandero",
        "brand": "Dacia"
        }
        ]
        """
        And one animal I like
        """json
        {
        "name": "Lion",
        "domesticated": false
        }
        """
    
    public class DemoStepDef {
    
    	@DocStringType(contentType = "json")
    	public List<Car> convertCars(String json) throws JsonProcessingException {
    		return new ObjectMapper().readValue(json,
    				new TypeReference<List<Car>>() {});
    	}
    
    	@DocStringType(contentType = "json")
    	public Animal convertAnimal(String json) throws JsonProcessingException {
    		return new ObjectMapper().readValue(json,
    				new TypeReference<Animal>() {});
    	}
    
    	@Given("I have the following cars")
    	public void i_have_cars(List<Car> cars) {
    		System.out.println(cars);
    	}
    
    	@And("one animal I like")
    	public void one_animal_I_like(Animal animal) {
    		System.out.println(animal);
    	}
    }
    
    public class Animal {
    	private String name;
    	private boolean domesticated;
    // setters and getters omitted 
    }
    
    public class Car {
    	private String name;
    	private String brand;
    // setters and getters omitted
    }
    

    Gives the following error:

    **Caused by: io.cucumber.docstring.CucumberDocStringException: There is already docstring type registered for 'json' and com.lumeon.cpm.models.records.Animal.**
    

    My feeling is that if jackson library is allowed for DocStringType annotation, then we should be able to leverage the full potential of it, and not be forced to have JsonNode as the only option. Having extra intermediary methods to convert to the actual types needed for the step definitions.

    Work-around at the moment:

    public class DemoThatWorksStepDef {
    
    	@DocStringType(contentType = "json")
    	public JsonNode json(String json) throws JsonProcessingException {
    		return new ObjectMapper().readTree(json);
    	}
    
    	public List<Car> convertCars(JsonNode jsonNode) throws IOException {
    		return new ObjectMapper().readValue(jsonNode.traverse(),
    				new TypeReference<List<Car>>() {});
    	}
    
    	public Animal convertAnimal(JsonNode jsonNode) throws IOException {
    		return new ObjectMapper().readValue(jsonNode.traverse(),
    				new TypeReference<Animal>() {});
    	}
    
    	@Given("I have the following cars")
    	public void i_have_cars(JsonNode jsonNode) throws IOException {
    		System.out.println(convertCars(jsonNode));
    	}
    
    	@And("one animal I like")
    	public void one_animal_I_like(JsonNode jsonNode) throws IOException {
    		System.out.println(convertAnimal(jsonNode));
    	}
    }
    
    :zap: enhancement :pray: help wanted 
    opened by PostelnicuGeorge 2
  • Provides an ObjectFactorySupplier to Runtime

    Provides an ObjectFactorySupplier to Runtime

    Is your pull request related to a problem? Please describe. This PR tries to solve two issues:

    • There's no way to provide your own ObjectFactory which was possible in previous versions (4.x and below)
    • If you provide a BackendSupplier, that object is not necessarily related to the ObjectFactory that is created on Runtime

    Describe the solution you have implemented Following the steps of BackendSupplier and FeatureSupplier, I added a new method to the builder to receive the ObjectFactorySupplier and I'm checking if that is provider it's not necessary to create a new one on .build().

    :baby_bottle: incomplete 
    opened by sidharta 1
Owner
Cucumber
Cucumber Open
Cucumber
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

pact-jvm JVM implementation of the consumer driven contract library pact. From the Ruby Pact website: Define a pact between service consumers and prov

Pact Foundation 889 Nov 29, 2021
Extensions/Plugins for JVM test frameworks

Jexter Extensions/Plugins for JVM test frameworks (JUnit 4, JUnit 5, ...) Get Jexter Binaries are available from Maven Central. Group Artifact Latest

Thundra 20 Aug 31, 2021
Cucumber DSL for testing RESTful Web Services

cukes-rest takes simplicity of Cucumber and provides bindings for HTTP specification. As a sugar on top, cukes-rest adds steps for storing and using r

C.T.Co 97 Oct 26, 2021
A project to cause (controlled) destruction on your jvm application

Perses Cause (controlled) destruction to your jvm application Perses (Ancient Greek: Πέρσης) was the Titan god of destruction. His name is derived fro

Nikolaos Kanakis 55 Nov 21, 2021
configuration library for JVM languages using HOCON files

Configuration library for JVM languages. If you have questions or are working on a pull request or just curious, please feel welcome to join the chat

Lightbend 5.5k Dec 4, 2021
Fault tolerance and resilience patterns for the JVM

Failsafe Failsafe is a lightweight, zero-dependency library for handling failures in Java 8+, with a concise API for handling everyday use cases and t

Jonathan Halterman 3.5k Dec 6, 2021
Fibers, Channels and Actors for the JVM

Quasar Fibers, Channels and Actors for the JVM Getting started Add the following Maven/Gradle dependencies: Feature Artifact Core (required) co.parall

Parallel Universe 4.3k Dec 2, 2021
Dead-Simple Packaging and Deployment for JVM Apps

Capsule Dead-Simple Packaging and Deployment for JVM Applications Capsule is a packaging and deployment tool for JVM applications. A capsule is a sing

Parallel Universe 1.1k Oct 22, 2021
Packages your JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X

About Packages your JAR, assets and a JVM for distribution on Windows, Linux and macOS, adding a native executable file to make it appear like a nativ

libgdx 2.3k Nov 30, 2021
Low-latency Financial Information Exchange (FIX) engine for the JVM

Philadelphia Philadelphia is a low-latency Financial Information Exchange (FIX) engine for the JVM. You can use Philadelphia to connect to stock excha

Parity 249 Nov 21, 2021
JitPack is a novel package repository for JVM and Android projects.

JitPack is a novel package repository for JVM and Android projects. It builds Git projects on demand and provides you with ready-to-use artifacts (jar, aar).

JitPack 2.2k Dec 6, 2021
High performance JVM JSON library

DSL-JSON library Fastest JVM (Java/Android/Scala/Kotlin) JSON library with advanced compile-time databinding support. Compatible with DSL Platform. Ja

New Generation Software Ltd 762 Nov 30, 2021
Model import deployment framework for retraining models (pytorch, tensorflow,keras) deploying in JVM Micro service environments, mobile devices, iot, and Apache Spark

The Eclipse Deeplearning4J (DL4J) ecosystem is a set of projects intended to support all the needs of a JVM based deep learning application. This mean

Eclipse Foundation 12.3k Nov 30, 2021
A JVM library to use RabbitMQ as an embedded service

Embedded RabbitMQ Compatibility: Builds: Linux OS X Windows Reports: Dist: Social: This library allows for the use of various RabbitMQ versions as if

Alejandro Rivera 85 Sep 2, 2021
:chart_with_upwards_trend: Capturing JVM- and application-level metrics. So you know what's going on.

Metrics ?? Capturing JVM- and application-level metrics. So you know what's going on. For more information, please see the documentation Versions Vers

Dropwizard 7.5k Nov 30, 2021
Get inside your JVM

nudge4j · nudge4j is a tiny piece of code to help great developers understand code better, debug less, have more fun. Overview With nudge4j you can: c

lorenzo puccetti 147 Nov 12, 2021
Prometheus instrumentation library for JVM applications

Prometheus JVM Client It supports Java, Clojure, Scala, JRuby, and anything else that runs on the JVM. Table of Contents Using Assets Javadocs Instrum

Prometheus 1.6k Nov 28, 2021
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!

OPEN HTML TO PDF OVERVIEW Open HTML to PDF is a pure-Java library for rendering arbitrary well-formed XML/XHTML (and even HTML5) using CSS 2.1 for lay

null 1.3k Nov 22, 2021
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.

pact-jvm JVM implementation of the consumer driven contract library pact. From the Ruby Pact website: Define a pact between service consumers and prov

Pact Foundation 889 Nov 29, 2021
Build highly concurrent, distributed, and resilient message-driven applications on the JVM

Akka We believe that writing correct concurrent & distributed, resilient and elastic applications is too hard. Most of the time it's because we are us

Akka Project 11.9k Nov 27, 2021
Vert.x is a tool-kit for building reactive applications on the JVM

Vert.x Core This is the repository for Vert.x core. Vert.x core contains fairly low-level functionality, including support for HTTP, TCP, file system

Eclipse Vert.x 12.5k Nov 28, 2021
Reactive Microservices for the JVM

Lagom - The Reactive Microservices Framework Lagom is a Swedish word meaning just right, sufficient. Microservices are about creating services that ar

Lagom Framework 2.6k Nov 29, 2021
Fault tolerance and resilience patterns for the JVM

Failsafe Failsafe is a lightweight, zero-dependency library for handling failures in Java 8+, with a concise API for handling everyday use cases and t

Jonathan Halterman 3.5k Nov 29, 2021
RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

RxJava: Reactive Extensions for the JVM RxJava is a Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-base

ReactiveX 45.5k Dec 5, 2021
A fast object pool for the JVM

Stormpot Stormpot is an object pooling library for Java. Use it to recycle objects that are expensive to create. The library will take care of creatin

Chris Vest 286 Oct 27, 2021
The Eta Programming Language, a dialect of Haskell on the JVM

Eta - Modern Haskell on the JVM The Eta programming language is a dialect of Haskell which runs on the JVM and has the following goals: accessibility

TypeLead 2.5k Dec 1, 2021
Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

OkHttp See the project website for documentation and APIs. HTTP is the way modern applications network. It’s how we exchange data & media. Doing HTTP

Square 41.2k Dec 1, 2021
Tools for tracking down memory / JVM problems & generating predictable-as-possible VM behaviour

Hawkshaw Tools for tracking down memory / JVM problems & generating predictable-as-possible VM behaviour You can Use Hawkshaw to mimic application obj

Martijn Verburg 40 Jan 9, 2021