@Before not firing with @RunWith(Cucumber.class)

924 views
Skip to first unread message

kaygee

unread,
Oct 28, 2011, 5:15:30 PM10/28/11
to Cukes
I'm attempting to run the example here

http://thomassundberg.wordpress.com/2011/10/18/testing-a-web-application-with-selenium-2/

I created my own example class which shows that they never get
executed. Am I missing something?

@RunWith(Cucumber.class)
@Feature("Login.feature")
public class CucumberLoginTest {

@BeforeClass
public static void beforeClass(){
System.out.println("@BeforeClass annotation.");
}

@AfterClass
public static void afterClass(){
System.out.println("@AfterClass annotation.");
}

@Before
public void prepare() {
System.out.println("@Before annotation.");
}

@After
public void cleanUp() {
System.out.println("@After annotation.");
}

@Test
public void test() {
System.out.println("@Test method.");
}

@Given("^I am at the CTRP login page$")
public void navigateToLoginPage() {
System.out.println("@Given annotation.");
}

@When("^I login with Login Id (.*) and the Password is (.*) and the
Account Source is (.*)$")
public void populateLoginFields(String username, String password,
String accountSource) {
System.out.println("@When annotation.");
}

@Then("^I should be logged in$")
public void assertValidLogin() {
System.out.println("@Then annotation.");
}

@Then("^I should not be logged in$")
public void assertInvalidLogin() {
System.out.println("@Then annotation.");
}

}

aslak hellesoy

unread,
Oct 28, 2011, 5:37:53 PM10/28/11
to cu...@googlegroups.com
On Fri, Oct 28, 2011 at 10:15 PM, kaygee <kg...@5amsolutions.com> wrote:
> I'm attempting to run the example here
>
> http://thomassundberg.wordpress.com/2011/10/18/testing-a-web-application-with-selenium-2/
>
> I created my own example class which shows that they never get
> executed. Am I missing something?
>

I think you're missing 2 things:

1) Cucumber currently ignores all org.junit.* annotations. You have to
use cucumber.annotation.Before. See
https://github.com/cucumber/cucumber-jvm/issues/76
2) The class with the @RunWith(Cucumber.class) should be empty. Define
the step definition methods (@Given/@When/@Then) in a separate class.
https://github.com/cucumber/cucumber-jvm/issues/77

Aslak

> --
> You received this message because you are subscribed to the Google Groups "Cukes" group.
> To post to this group, send email to cu...@googlegroups.com.
> To unsubscribe from this group, send email to cukes+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages