Skip to content

Commit

Permalink
Revert "- implemented junit 5 batching (#3568)"
Browse files Browse the repository at this point in the history
This reverts commit e1b2c75.
  • Loading branch information
wakaleo committed Nov 7, 2024
1 parent e1b2c75 commit 505a15c
Show file tree
Hide file tree
Showing 56 changed files with 76 additions and 911 deletions.
6 changes: 0 additions & 6 deletions serenity-cucumber/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,5 @@
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit5</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import io.cucumber.core.feature.Options;
import io.cucumber.core.runtime.FeaturePathFeatureSupplier;
import io.cucumber.messages.types.*;
import net.serenitybdd.cucumber.utils.PathUtils;
import net.serenitybdd.cucumber.suiteslicing.TestStatistics;
import net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenario;
import net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenarios;
import net.serenitybdd.cucumber.util.PathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -85,12 +85,12 @@ private Function<Feature, List<WeightedCucumberScenario>> getScenarios() {
.filter(child -> child.getScenario() != null && child.getScenario().isPresent())
.map(FeatureChild::getScenario)
.map(scenarioDefinition -> new WeightedCucumberScenario(
PathUtils.getAsFile(mapsForFeatures.get(cucumberFeature)).getName(),
cucumberFeature.getName(),
scenarioDefinition.get().getName(),
scenarioWeightFor(cucumberFeature, scenarioDefinition.get()),
tagsFor(cucumberFeature, scenarioDefinition.get()),
scenarioCountFor(scenarioDefinition.get())))
PathUtils.getAsFile(mapsForFeatures.get(cucumberFeature)).getName(),
cucumberFeature.getName(),
scenarioDefinition.get().getName(),
scenarioWeightFor(cucumberFeature, scenarioDefinition.get()),
tagsFor(cucumberFeature, scenarioDefinition.get()),
scenarioCountFor(scenarioDefinition.get())))
.collect(toList());
} catch (Throwable e) {
throw new IllegalStateException(String.format("Could not extract scenarios from %s", mapsForFeatures.get(cucumberFeature)), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package io.cucumber.junit;

import static io.cucumber.core.runtime.SynchronizedEventBus.synchronize;
import static io.cucumber.junit.FileNameCompatibleNames.uniqueSuffix;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import static net.thucydides.model.ThucydidesSystemProperty.SERENITY_BATCH_COUNT;
import static net.thucydides.model.ThucydidesSystemProperty.SERENITY_BATCH_NUMBER;
import static net.thucydides.model.ThucydidesSystemProperty.SERENITY_FORK_COUNT;
import static net.thucydides.model.ThucydidesSystemProperty.SERENITY_FORK_NUMBER;
import io.cucumber.core.eventbus.EventBus;
import io.cucumber.core.feature.FeatureParser;
import io.cucumber.core.filter.Filters;
Expand All @@ -11,17 +20,25 @@
import io.cucumber.core.resource.ClassLoaders;
import io.cucumber.core.runtime.*;
import io.cucumber.plugin.Plugin;
import io.cucumber.tagexpressions.Expression;
import java.net.URI;
import java.time.Clock;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import net.serenitybdd.cucumber.SerenityOptions;
import net.serenitybdd.cucumber.suiteslicing.CucumberSuiteSlicer;
import net.serenitybdd.cucumber.suiteslicing.ScenarioFilter;
import net.serenitybdd.cucumber.suiteslicing.TestStatistics;
import net.serenitybdd.cucumber.suiteslicing.WeightedCucumberScenarios;
import io.cucumber.tagexpressions.Expression;
import net.serenitybdd.cucumber.SerenityOptions;
import net.serenitybdd.cucumber.util.PathUtils;
import net.serenitybdd.cucumber.util.Splitter;
import net.thucydides.core.steps.StepEventBus;
import net.thucydides.model.ThucydidesSystemProperty;
import net.thucydides.model.environment.SystemEnvironmentVariables;
import net.thucydides.core.steps.StepEventBus;
import net.thucydides.model.requirements.reports.MultipleSourceRequirmentsOutcomeFactory;
import net.thucydides.model.util.EnvironmentVariables;
import org.junit.runner.Description;
import org.junit.runner.manipulation.NoTestsRemainException;
Expand All @@ -33,21 +50,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.time.Clock;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import static io.cucumber.core.runtime.SynchronizedEventBus.synchronize;
import static io.cucumber.junit.FileNameCompatibleNames.uniqueSuffix;
import static java.util.Arrays.stream;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toList;
import static net.thucydides.model.ThucydidesSystemProperty.*;

public class CucumberSerenityBaseRunner extends ParentRunner<ParentRunner<?>> {

private static final Logger LOGGER = LoggerFactory.getLogger(CucumberSerenityBaseRunner.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.google.gson.GsonBuilder;
import io.cucumber.gherkin.CucumberScenarioLoader;
import net.serenitybdd.model.environment.ConfiguredEnvironment;
import net.serenitybdd.cucumber.utils.PathUtils;
import net.serenitybdd.cucumber.util.PathUtils;
import net.thucydides.model.util.EnvironmentVariables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.serenitybdd.cucumber.suiteslicing;

import io.cucumber.gherkin.CucumberScenarioLoader;
import net.serenitybdd.cucumber.utils.TagParser;
import net.serenitybdd.cucumber.util.TagParser;

import java.net.URI;
import java.util.List;
Expand All @@ -28,4 +28,4 @@ public WeightedCucumberScenarios scenarios(int batchNumber, int batchCount, int
private Predicate<WeightedCucumberScenario> forSuppliedTags(List<String> tagFilters) {
return cucumberScenario -> TagParser.parseFromTagFilters(tagFilters).evaluate(newArrayList(cucumberScenario.tags));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.serenitybdd.cucumber.suiteslicing;


import net.serenitybdd.cucumber.utils.BigDecimalAverageCollector;
import net.serenitybdd.cucumber.util.BigDecimalAverageCollector;
import net.thucydides.model.util.Inflector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package net.serenitybdd.cucumber.suiteslicing;

import net.serenitybdd.cucumber.utils.BigDecimalAverageCollector;
import net.serenitybdd.cucumber.util.BigDecimalAverageCollector;

import java.math.BigDecimal;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package net.serenitybdd.cucumber.utils;
package net.serenitybdd.cucumber.util;

import java.math.BigDecimal;
import java.util.Collections;
Expand Down Expand Up @@ -79,4 +79,4 @@ void add(BigDecimal successRate) {
sum = sum.add(successRate);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.serenitybdd.cucumber.suiteslicing;

import io.cucumber.gherkin.CucumberScenarioLoader;

import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -81,7 +79,7 @@ public void scenariosOfAllSlicesBetweenAllJvmShouldBeTheSame() throws URISyntaxE
.sliceInto(sliceCount);

for (int i = 0; i < jvm1Slices.size(); i++) {
assertThat(jvm1Slices.get(i).scenarios, Matchers.contains(buildMatchingCucumberScenario(jvm2Slices.get(i))));
assertThat(jvm1Slices.get(i).scenarios, contains(buildMatchingCucumberScenario(jvm2Slices.get(i))));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package net.serenitybdd.cucumber.suiteslicing;


import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;

Expand Down Expand Up @@ -36,20 +35,20 @@ public void setup() throws Exception {

@Test
public void shouldReturnOnlyScenariosWithSpecifiedTags() {
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("@shouldPass")).scenarios, Matchers.contains(expectedScenario1));
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("@shouldPass")).scenarios, contains(expectedScenario1));
}

@Test
public void noSuppliedTagsMeansReturnAllScenarios() {
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList()).scenarios, Matchers.contains(expectedScenario1, expectedScenario2));
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList()).scenarios, contains(expectedScenario1, expectedScenario2));
}

@Test
public void shouldSupportNotInTheTagExpression() {
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("not @shouldPass")).scenarios, Matchers.contains(expectedScenario2));
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("not @shouldPass")).scenarios, contains(expectedScenario2));
}
@Test
public void shouldSupportOldExclusionSyntaxInTheTagExpression() {
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("~@shouldPass")).scenarios, Matchers.contains(expectedScenario2));
assertThat(cucumberSuiteSlicer.scenarios(1, 1, 1, 1, asList("~@shouldPass")).scenarios, contains(expectedScenario2));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public void scenarioWeightForShouldReturnAverageAllDurationsForUnknownScenario()
assertThat(statistics.scenarioWeightFor("Yo", "I don't exist matey"), is(new BigDecimal("5.53")));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public void scenarioWeightForScenarioWithBackgroundAndScenario() {
assertThat(stats.scenarioWeightFor("Locate a customer by personal details and Reg Number", "Locating a customer using a unique criterion"), is(new BigDecimal("4")));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public void scenarioWeightForShouldReturnAverageDurationForUnknownScenario() thr
statistics.scenarioWeightFor("Yo", "I don't exist matey");
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.serenitybdd.cucumber.suiteslicing;

import io.cucumber.junit.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.Ignore;
import org.junit.runner.RunWith;



@Ignore
@RunWith(CucumberWithSerenity.class)
@CucumberOptions(glue = "net.serenitybdd.cucumber.smoketests", features="classpath:smoketests")
public class SlicedTestRunner {

/*
Experimental test runner where parameters can changed in order to run specific portions of the test suite. For instance create a run configuration and paste the following into the VM Options:
-Dserenity.batch.count=3 -Dserenity.batch.number=2 -Dserenity.fork.number=1 -Dserenity.fork.count=2 -Dserenity.test.statistics.dir=/statistics
And you should see the following logged in the console:
16:49:18.551 [main] INFO n.s.cucumber.CucumberWithSerenity - Running slice 2 of 3 using fork 1 of 2 from feature paths [classpath:smoketests]
The Test output should show some features selected and some scenarios run and some not run. This is expected!
*/

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.serenitybdd.cucumber.suiteslicing;

import org.hamcrest.core.Is;
import org.junit.Test;

import java.math.BigDecimal;
Expand All @@ -22,7 +21,7 @@ public void slicingMoreThinlyThanTheNumberOfScenariosShouldResultInSomeEmptySlic
List<WeightedCucumberScenarios> weightedCucumberScenarios = oneScenario.sliceInto(100);
assertThat(weightedCucumberScenarios, hasSize(100));
assertThat(weightedCucumberScenarios.get(0).scenarios, hasSize(1));
assertThat(weightedCucumberScenarios.get(0).scenarios.get(0), Is.is(weightedCucumberScenario));
assertThat(weightedCucumberScenarios.get(0).scenarios.get(0), is(weightedCucumberScenario));
assertThat(weightedCucumberScenarios.get(1).scenarios, hasSize(0));
assertThat(weightedCucumberScenarios.get(99).scenarios, hasSize(0));
}
Expand All @@ -32,7 +31,7 @@ public void slicingASliceIntoOneSliceOfOneShouldBeTheSameAsAllScenarios() {
List<WeightedCucumberScenario> scenarios = Collections.singletonList(new WeightedCucumberScenario("test.feature", "featurename", "scenarioname", BigDecimal.ONE, emptySet(), 0));
WeightedCucumberScenarios oneScenario = new WeightedCucumberScenarios(scenarios);
WeightedCucumberScenarios fork1 = oneScenario.slice(1).of(1);
assertThat(oneScenario, Is.is(fork1));
assertThat(oneScenario, is(fork1));
}

}
}
32 changes: 2 additions & 30 deletions serenity-junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,8 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit5.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- TEST DEPENDENCIES -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-tag-expressions</artifactId>
<version>2.0.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand Down Expand Up @@ -99,7 +82,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand All @@ -125,16 +108,5 @@
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>${commons.csv.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit 505a15c

Please sign in to comment.