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

cucumber.steps.AuthenticationTokenSteps - this class doesn't have an empty or a page enabled constructor" #2173

Closed
jainamit1712 opened this issue Jul 16, 2020 · 3 comments
Labels

Comments

@jainamit1712
Copy link

1.9.12 1.9.5 1.9.12 net.serenity-bdd serenity-core ${serenity.version} net.serenity-bdd serenity-junit ${serenity.version} net.serenity-bdd serenity-rest-assured ${serenity.version} net.serenity-bdd serenity-cucumber ${serenity.cucumber.version} net.serenity-bdd serenity-picocontainer 1.0.25

I tried to implement very simple class to retrieve token and want to share across different scenarios

public class AuthenticationTokenSteps {

TestContextAPI testContext;

public AuthenticationTokenSteps(TestContextAPI testContext) {
	this.testContext = testContext;
}

@Steps
SerenityCommonMethodsSteps cmnMethod;


@Given("user calls (.+) with (.+) http request")
public void user_calls_with_http_request(String string, String string2) throws Exception {
	
 testContext. AccessToken= cmnMethod.getAccessToken();

  
}

}

This is my contextclass

public class TestContextAPI {

protected RequestSpecification req_spec=null;
protected Response resp=null;
protected String AccessToken = null;

}

I dont know why it is complaining this class doesn't have an empty or a page enabled constructor. i have specified the constructor.

Please suggest how can i achieve this.

@wakaleo
Copy link
Member

wakaleo commented Jul 17, 2020

I'm not clear what you are trying to do?

@jainamit1712
Copy link
Author

jainamit1712 commented Jul 17, 2020

I want to share accessToken value across all my step definition class using pico-container

Please refer below two classes TestContextApI(responsible to share accessToken value) and AuthenticationTokenSteps(calling step)

In the below example cmnMethod.getAccessToken(); returns me accessToken which i am storing in textcontext.accessToken so that i can share the value across different stepdefs.

In order to achieve this i have created constructor below AuthenticationTokenSteps and passed TextContextAPI class.

When i run the test it complaint this class doesn't have an empty or a page enabled constructor", but if you see in my AuthenticationTokenSteps class i have defined the constructor.

public class TestContextAPI {
protected String accessToken = null;
}

public class AuthenticationTokenSteps {

TestContextAPI testContext;

public AuthenticationTokenSteps(TestContextAPI testContext) {
this.testContext = testContext;
}

@steps
SerenityCommonMethodsSteps cmnMethod;

@given("user calls (.+) with (.+) http request")
public void user_calls_with_http_request(String string, String string2) throws Exception {

testContext. accessToken= cmnMethod.getAccessToken(); ------this method retuns me accessToken
}

Also, i am using version 1.0.25 version for serenity-picocontainer

@jainamit1712
Copy link
Author

I am able to achieve this with cucumber by implementing same logic but i am trying to do with serenity-bdd it is complaining "this class doesn't have an empty or a page enabled constructor"

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants