Skip to content

Commit

Permalink
[Core] Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
mpkorstanje committed Sep 4, 2020
1 parent fc56498 commit bf00837
Show file tree
Hide file tree
Showing 11 changed files with 381 additions and 398 deletions.
Expand Up @@ -26,7 +26,7 @@ public StubHookDefinition(RuntimeException exception) {

@Override
public void execute(TestCaseState state) {
if(action != null){
if (action != null) {
action.accept(state);
}
if (exception != null) {
Expand Down
347 changes: 166 additions & 181 deletions core/src/test/java/io/cucumber/core/plugin/JUnitFormatterTest.java

Large diffs are not rendered by default.

@@ -1,5 +1,7 @@
package io.cucumber.core.plugin;

import io.cucumber.core.backend.StubHookDefinition;
import io.cucumber.core.backend.StubStepDefinition;
import io.cucumber.core.feature.TestFeatureParser;
import io.cucumber.core.gherkin.Feature;
import io.cucumber.core.options.RuntimeOptionsBuilder;
Expand All @@ -8,8 +10,6 @@
import io.cucumber.core.runtime.Runtime;
import io.cucumber.core.runtime.Runtime.Builder;
import io.cucumber.core.runtime.StubBackendSupplier;
import io.cucumber.core.backend.StubHookDefinition;
import io.cucumber.core.backend.StubStepDefinition;
import io.cucumber.core.runtime.StubFeatureSupplier;
import io.cucumber.core.runtime.TimeServiceEventBus;
import io.cucumber.plugin.event.Result;
Expand Down
@@ -1,11 +1,11 @@
package io.cucumber.core.plugin;

import io.cucumber.core.backend.StepDefinition;
import io.cucumber.core.backend.StubStepDefinition;
import io.cucumber.core.eventbus.EventBus;
import io.cucumber.core.feature.TestFeatureParser;
import io.cucumber.core.gherkin.Feature;
import io.cucumber.core.runner.TestHelper;
import io.cucumber.core.backend.StubStepDefinition;
import io.cucumber.core.runtime.TimeServiceEventBus;
import io.cucumber.core.stepexpression.StepExpression;
import io.cucumber.core.stepexpression.StepExpressionFactory;
Expand Down
79 changes: 34 additions & 45 deletions core/src/test/java/io/cucumber/core/plugin/RerunFormatterTest.java
Expand Up @@ -35,9 +35,8 @@ void should_leave_report_empty_when_exit_code_is_zero() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("passed step"),
new StubStepDefinition("skipped step", new TestAbortedException())
))
new StubStepDefinition("passed step"),
new StubStepDefinition("skipped step", new TestAbortedException())))
.build()
.run();

Expand All @@ -60,9 +59,8 @@ void should_put_data_in_report_when_exit_code_is_non_zero() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("failed step", new StubException()),
new StubStepDefinition("pending step", new StubPendingException())
))
new StubStepDefinition("failed step", new StubException()),
new StubStepDefinition("pending step", new StubPendingException())))
.build()
.run();

Expand All @@ -83,10 +81,9 @@ void should_use_scenario_location_when_scenario_step_fails() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step", new StubException())
))
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step", new StubException())))
.build()
.run();

Expand All @@ -108,10 +105,9 @@ void should_use_scenario_location_when_background_step_fails() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("background step", new StubException()),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")
))
new StubStepDefinition("background step", new StubException()),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")))
.build()
.run();

Expand All @@ -135,10 +131,9 @@ void should_use_example_row_location_when_scenario_outline_fails() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("executing first row"),
new StubStepDefinition("executing second row", new StubException()),
new StubStepDefinition("everything is ok")
))
new StubStepDefinition("executing first row"),
new StubStepDefinition("executing second row", new StubException()),
new StubStepDefinition("everything is ok")))
.build()
.run();

Expand All @@ -159,14 +154,12 @@ void should_use_scenario_location_when_before_hook_fails() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition(new StubException())),
asList(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")
),
emptyList()
))
singletonList(new StubHookDefinition(new StubException())),
asList(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")),
emptyList()))
.build()
.run();

Expand All @@ -187,14 +180,12 @@ void should_use_scenario_location_when_after_hook_fails() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
emptyList(),
asList(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")
),
singletonList(new StubHookDefinition(new StubException()))
))
emptyList(),
asList(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")),
singletonList(new StubHookDefinition(new StubException()))))
.build()
.run();

Expand All @@ -217,11 +208,10 @@ void should_one_entry_for_feature_with_many_failing_scenarios() {
.withFeatureSupplier(new StubFeatureSupplier(feature))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step"),
new StubStepDefinition("second step", new StubException()),
new StubStepDefinition("third step", new StubException()),
new StubStepDefinition("forth step")
))
new StubStepDefinition("first step"),
new StubStepDefinition("second step", new StubException()),
new StubStepDefinition("third step", new StubException()),
new StubStepDefinition("forth step")))
.build()
.run();

Expand All @@ -246,16 +236,15 @@ void should_one_entry_for_each_failing_feature() {
.withFeatureSupplier(new StubFeatureSupplier(feature1, feature2))
.withAdditionalPlugins(new RerunFormatter(out))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step"),
new StubStepDefinition("second step", new StubException()),
new StubStepDefinition("third step", new StubException()),
new StubStepDefinition("forth step")
))
new StubStepDefinition("first step"),
new StubStepDefinition("second step", new StubException()),
new StubStepDefinition("third step", new StubException()),
new StubStepDefinition("forth step")))
.build()
.run();

assertThat(out,
isBytesEqualTo("classpath:path/first.feature:2\nclasspath:path/second.feature:2\n"));
isBytesEqualTo("classpath:path/first.feature:2\nclasspath:path/second.feature:2\n"));
}

}
61 changes: 27 additions & 34 deletions core/src/test/java/io/cucumber/core/plugin/TeamCityPluginTest.java
Expand Up @@ -47,10 +47,9 @@ void should_handle_scenario_outline() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")
))
new StubStepDefinition("first step"),
new StubStepDefinition("second step"),
new StubStepDefinition("third step")))
.build()
.run();

Expand Down Expand Up @@ -116,11 +115,10 @@ void should_handle_nameless_attach_events() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition(
(TestCaseState state) -> state.attach("A message", "text/plain", null))),
singletonList(new StubStepDefinition("first step")),
emptyList()
))
singletonList(new StubHookDefinition(
(TestCaseState state) -> state.attach("A message", "text/plain", null))),
singletonList(new StubStepDefinition("first step")),
emptyList()))
.build()
.run();

Expand All @@ -141,10 +139,9 @@ void should_handle_write_events() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition((TestCaseState state) -> state.log("A message"))),
singletonList(new StubStepDefinition("first step")),
emptyList()
))
singletonList(new StubHookDefinition((TestCaseState state) -> state.log("A message"))),
singletonList(new StubStepDefinition("first step")),
emptyList()))
.build()
.run();

Expand All @@ -165,11 +162,10 @@ void should_handle_attach_events() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition(
(TestCaseState state) -> state.attach("A message", "text/plain", "message.txt"))),
singletonList(new StubStepDefinition("first step")),
emptyList()
))
singletonList(new StubHookDefinition(
(TestCaseState state) -> state.attach("A message", "text/plain", "message.txt"))),
singletonList(new StubStepDefinition("first step")),
emptyList()))
.build()
.run();

Expand All @@ -190,8 +186,7 @@ void should_print_error_message_for_failed_steps() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
new StubStepDefinition("first step", new StubException("Step failed", "the stack trace")))
)
new StubStepDefinition("first step", new StubException("Step failed", "the stack trace"))))
.build()
.run();

Expand Down Expand Up @@ -232,10 +227,9 @@ void should_print_error_message_for_before_hooks() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition(new StubException("Step failed", "the stack trace"))),
singletonList(new StubStepDefinition("first step")),
emptyList()
))
singletonList(new StubHookDefinition(new StubException("Step failed", "the stack trace"))),
singletonList(new StubStepDefinition("first step")),
emptyList()))
.build()
.run();

Expand All @@ -258,16 +252,15 @@ void should_print_location_hint_for_hooks() {
.withAdditionalPlugins(new TeamCityPlugin(new PrintStream(out)))
.withEventBus(new TimeServiceEventBus(fixed(EPOCH, of("UTC")), UUID::randomUUID))
.withBackendSupplier(new StubBackendSupplier(
singletonList(new StubHookDefinition() {

@Override
public String getLocation() {
return "com.example.HookDefinition.beforeHook()";
}
}),
singletonList(new StubStepDefinition("first step")),
emptyList()
))
singletonList(new StubHookDefinition() {

@Override
public String getLocation() {
return "com.example.HookDefinition.beforeHook()";
}
}),
singletonList(new StubStepDefinition("first step")),
emptyList()))
.build()
.run();

Expand Down

0 comments on commit bf00837

Please sign in to comment.