@@ -0,0 +1,2933 @@
+package com.merchantwarehouse.qa.cukes;%0D%0A%0D%0Aimport cucumber.api.java.en.Given;%0D%0Aimport cucumber.api.java.en.Then;%0D%0Aimport cucumber.api.java.en.When;%0D%0Aimport org.junit.AfterClass;%0D%0Aimport org.junit.BeforeClass;%0D%0Aimport org.junit.runner.RunWith;%0D%0Aimport static org.junit.Assert.assertEquals;%0D%0A%0D%0A/**%0D%0A * This class tests the integration with various junit features (@BeforeClass and @AfterClass). It also has the side%0D%0A * effect of testing that the same Gherkin rules and the same Cucumber Step Definitions may appear in more than one%0D%0A * file without them conflicting.%0D%0A *%0D%0A * @author dominicl%0D%0A */%0D%0A@RunWith(Cucumber.class)%0D%0A@Cucumber.Options(features = %22DifferentlyNamedFeature.feature%22)%0D%0Apublic class JunitIntegrationTest %7B%0D%0A%0D%0A    // counters of how many times junit's beforeclass/afterclass were called. these should be 1x each.%0D%0A    private static int countOfTimesBeforeClassWasCalled = 0;%0D%0A    private static int countOfTimesAfterClassWasCalled = 0;%0D%0A%0D%0A    // counters of how many times given/when/then were called. given the above feature file, these should be 2x each.%0D%0A    // this is important, because there are 2 Gherkin feature files with the same rules, so the stock version of cucumber%0D%0A    // would run these rules 4x each. actually, it would fail to run at all because both this class and the InheritanceTest%0D%0A    // and GlueClassTest define identical step definitions. we'll validate the counters in @AfterClass%0D%0A    private static int countOfTimesGivenWasCalled = 0;%0D%0A    private static int countOfTimesWhenWasCalled = 0;%0D%0A    private static int countOfTimesThenWasCalled = 0;%0D%0A%0D%0A    @BeforeClass%0D%0A    public static void beforeClass() %7B%0D%0A        countOfTimesBeforeClassWasCalled++;%0D%0A        System.out.format(%22Called beforeClass() %25d times%22, countOfTimesBeforeClassWasCalled).println();%0D%0A    %7D%0D%0A%0D%0A    @AfterClass%0D%0A    public static void afterClass() %7B%0D%0A        countOfTimesAfterClassWasCalled++;%0D%0A        System.out.format(%22Called afterClass() %25d times%22, countOfTimesAfterClassWasCalled).println();%0D%0A%0D%0A        assertEquals(%22countOfTimesBeforeClassWasCalled%22, 1, countOfTimesBeforeClassWasCalled);%0D%0A        assertEquals(%22countOfTimesAfterClassWasCalled%22, 1, countOfTimesAfterClassWasCalled);%0D%0A%0D%0A        assertEquals(%22countOfTimesGivenWasCalled%22, 2, countOfTimesGivenWasCalled);%0D%0A        assertEquals(%22countOfTimesWhenWasCalled%22, 2, countOfTimesWhenWasCalled);%0D%0A        assertEquals(%22countOfTimesThenWasCalled%22, 2, countOfTimesThenWasCalled);%0D%0A    %7D%0D%0A%0D%0A    @Then(%22%5Ethe total should be (%5C%5Cd+)$%22)%0D%0A    public void then_the_total_should_be(Integer total) %7B%0D%0A        countOfTimesThenWasCalled++;%0D%0A    %7D%0D%0A    %0D%0A    @Given(%22%5Etwo integers (%5C%5Cd+) and (%5C%5Cd+)$%22)%0D%0A    public final void given_two_integers(final Integer a, final Integer b) %7B%0D%0A        countOfTimesGivenWasCalled++;%0D%0A    %7D%0D%0A%0D%0A    @When(%22%5Eyou add them together$%22)%0D%0A    public final void when_you_add_them_together() %7B%0D%0A        countOfTimesWhenWasCalled++;%0D%0A    %7D%0D%0A%7D%0D%0A

Test the Cucumber + JUnit integration