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

Runner file #3

Closed
grandmaximum opened this issue Aug 17, 2021 · 11 comments
Closed

Runner file #3

grandmaximum opened this issue Aug 17, 2021 · 11 comments

Comments

@grandmaximum
Copy link

I don't have the option to perform a pull request (company restriction), so I write here instead.

I added so the user have the option to define Steps and Feature files from a "runner file":

        runtimeOptionsBuilder.addGlue(URI.create("classpath:/" + stepsPath));
        runtimeOptionsBuilder.addFeature(FeatureWithLines.create(URI.create("classpath:/" + featurePath), Collections.emptyList()));

        if (tags != null)
        {
            for (String tag : tags)
            {
                runtimeOptionsBuilder.addTagFilter(TagExpressionParser.parse(tag));
            }
        }

And then implemented some setters:

   public void setGlue(String stepsPath)
    {
        this.stepsPath = stepsPath;
    }

    public void setFeature(String featurePath)
    {
        this.featurePath = featurePath;
    }

    public void setTag(String tags)
    {
        this.tags = Arrays.asList(tags.split("\\s*,\\s*"));
    }

in order for my "runner" class to look like this:

@QuarkusTest
public class HelloRunner extends CucumberQuarkusTest
{
    @BeforeEach
    public void setup()
    {
        super.setGlue("ekn/information/hellocucumber");
        super.setFeature("Hello.feature");
        super.setTag("@smoke");
    }
}

I used the logics applied by @drubio-tlnd in https://github.com/quarkusio/quarkus/issues/11045#issuecomment-769663017, which works if only one tag is used, but fails when there are many tags. Any idea why?

@christophd
Copy link
Contributor

@grandmaximum can you please have a look at #4 which was released with #5. It may help you to set custom glue, features and tags via @CucumberOptions.

let me know if this works for you

@grandmaximum
Copy link
Author

grandmaximum commented Sep 7, 2021

@christophd It seems like the tag feature isn't really working. Whether or not I use tags and define them in the runner file, all the tests in the specified .feature-file is still run.

EDIT:
The problem is that we don't filter the tests based on the tag expressions, which could be solved this way: quarkusio/quarkus#11045 (comment)

A bit ironic that this was the broken link in my last post.

@christophd
Copy link
Contributor

@grandmaximum let me check. how do you define the tags in the runner file?

@grandmaximum
Copy link
Author

grandmaximum commented Sep 7, 2021

@RunWith(Cucumber.class)
@CucumberOptions(
monochrome = true,
features = "src/test/java/ekn/information/v/hello/Hello.feature",
glue ="ekn.information.v.hello",
tags = "@Saknar"
)
public class HelloRunnerQuarkiverse extends CucumberQuarkusTest
{
}

See my edited answer on the last post.

@christophd
Copy link
Contributor

christophd commented Sep 7, 2021

@grandmaximum thanks for reporting! Fixed the tag filtering support in #8

@grandmaximum
Copy link
Author

@stuartwdouglas When are you planning on 0.4.0? Would be awesome if I could test the tag filtering.

@stuartwdouglas
Copy link
Contributor

Here you go: #9

Might take a bit to get into central.

@grandmaximum
Copy link
Author

grandmaximum commented Sep 16, 2021

I ran into the same problem as mentioned in quarkusio/quarkus#10435.

When I run a steps method which uses a Restassured call I get the following error:

      java.util.ServiceConfigurationError: org.apache.groovy.json.FastStringServiceFactory: org.apache.groovy.json.DefaultFastStringServiceFactory not a subtype
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1236)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
	at org.apache.groovy.json.internal.FastStringUtils$ServiceHolder.loadService(FastStringUtils.java:41)
	at org.apache.groovy.json.internal.FastStringUtils$ServiceHolder.<clinit>(FastStringUtils.java:33)
	at org.apache.groovy.json.internal.FastStringUtils.getService(FastStringUtils.java:55)
	at org.apache.groovy.json.internal.FastStringUtils.toCharArray(FastStringUtils.java:66)
	at org.apache.groovy.json.internal.CharBuf.addJsonEscapedString(CharBuf.java:341)
	at org.apache.groovy.json.internal.CharBuf.addJsonEscapedString(CharBuf.java:337)
	at groovy.json.JsonOutput.prettyPrint(JsonOutput.java:213)
	at groovy.json.JsonOutput$prettyPrint.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
	at io.restassured.internal.path.json.JsonPrettifier.prettifyJson(JsonPrettifier.groovy:25)
	at io.restassured.internal.path.json.JsonPrettifier$prettifyJson.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
	at io.restassured.internal.support.Prettifier.prettify(Prettifier.groovy:60)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43)
	at 
...

The problem occures on the first class being loaded by RestAssures classloader. Is there a possible way around this or is RestAssured simply imcompatible with dynamic tests (@testfactory) and thus quarkus-cucumber?

My RestAssured call:

        responseSpara = RestAssured.given().log().all()
                                            .contentType("application/json")
                                            .body(userData)
                                            .header("USERID", "TESTID")
                                            .header("USERNAME", "TESTER")
                                            .when()
                                            .post("/save")
                                            .then()
                                            .statusCode(200)
                                            .extract()
                                            .response();

@stuartwdouglas

@christophd
Copy link
Contributor

@grandmaximum the issue regarding RestAssured seems to be different. Could you please open a separate issue for this?

About to close the initial issue regarding Runner file then

@bella-daza
Copy link

bella-daza commented Oct 15, 2021

Hi, I try extension but i don't have any result. I have an app Quarkus. I did like here : https://github.com/quarkiverse/quarkus-cucumber/blob/main/docs/modules/ROOT/pages/index.adoc

so, i have a runner file :

`package test.it.runner;

import io.cucumber.junit.Cucumber;
import io.quarkiverse.cucumber.CucumberOptions;
import io.quarkiverse.cucumber.CucumberQuarkusTest;

import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(features = { "src/test/resources/test/it" }, glue = {
"test.it" }, plugin = { "pretty", "html:target/cucumber-reports/report.html",
"junit:target/cucumber-reports/junit-report.xml", "io.qameta.allure.cucumber6jvm.AllureCucumber6Jvm" })

public class RunnerCucumberIT extends CucumberQuarkusTest {
public static void main(String[] args) {
runMain(RunnerCucumberIT.class, args);
}
}
`
And I have a .feature file and a test file but when I did play to RunnerCucumberIT any test is started. And is I got mvn verify only unit test are started.

My test file for bdd - cucumber test is methods empty so, I wait errors about that but nothig is comming.

Is there any other documentation that I can follow ?

Thanks you :)

@christophd
Copy link
Contributor

@bella-daza could you please open separate issue. Your problem seems to not be related to this one.

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

No branches or pull requests

4 participants