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

Create assertions for Pioneer (#232) #245

Merged
merged 22 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1f3293e
Created PioneerAssert in a container class (fluent API is hard). Rewr…
Michael1993 Apr 28, 2020
b20525c
WIP commit. Moved assertion class to separate package.
Michael1993 Apr 29, 2020
acb0f85
Merge branch 'master' of https://github.com/junit-pioneer/junit-pione…
Michael1993 Apr 29, 2020
0dd7f2f
Implementation of an experimental approach to asserting Pioneer asser…
Michael1993 Apr 30, 2020
6e946fc
Changed ExceptionAssert into AbstractThrowableAssert
Michael1993 May 1, 2020
6640c72
WIP commit
Michael1993 May 6, 2020
f726aff
Added some more paths to the assertions for better readability.
Michael1993 May 6, 2020
d942f9d
WIP - documentation.
Michael1993 May 10, 2020
5a401c4
Added EntryPoint for both generic and Pioneer specific assertions.
Michael1993 May 26, 2020
03aa914
Added static import for `assertThat` in PioneerAssert
Michael1993 May 26, 2020
ee30434
Spotless. Again.
Michael1993 May 26, 2020
9558c26
This commit is basically a guess.
Michael1993 May 27, 2020
95f94e9
Reverting previous commit.
Michael1993 May 27, 2020
0b1ffb9
Rollback breaking changes.
Michael1993 May 27, 2020
f1f557b
Merge branch 'master' into issue/232-pioneer-assert
Michael1993 Jun 25, 2020
6c201c2
WIP
Michael1993 Jun 25, 2020
3bd4d56
Refactored Pioneer assertions to be simpler, easier to use.
Michael1993 Jun 25, 2020
34ddce7
Documentation update.
Michael1993 Jun 25, 2020
64b6864
Merge branch 'master' into issue/232-pioneer-assert
Michael1993 Jul 3, 2020
0903920
Small changes
Jul 14, 2020
6bc61b5
Merge branch 'master' of https://github.com/junit-pioneer/junit-pione…
Michael1993 Jul 14, 2020
87c93b0
Merge fix.
Michael1993 Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/test/java/org/junitpioneer/jupiter/DefaultLocaleTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

package org.junitpioneer.jupiter;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junitpioneer.testkit.PioneerTestKit.executeTestClass;
import static org.junitpioneer.testkit.PioneerTestKit.executeTestMethod;
import static org.junitpioneer.testkit.assertion.PioneerAssert.EntryPoint.assertThat;

import java.util.Locale;

Expand Down Expand Up @@ -98,7 +98,7 @@ void setUp() {
void shouldExecuteTestsWithConfiguredLocale() {
ExecutionResults results = executeTestClass(ClassLevelTestCase.class);

assertThat(results.numberOfSucceededTests()).isEqualTo(2);
assertThat(results).hasNumberOfTests(2).thatSucceeded();
}

@AfterEach
Expand Down Expand Up @@ -177,7 +177,7 @@ void shouldFailWhenNothingIsConfigured() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailMissingConfiguration");

results.assertTestFailedWithThrowable(ExtensionConfigurationException.class);
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -186,7 +186,7 @@ void shouldFailWhenVariantIsSetButCountryIsNot() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailMissingCountry");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -195,7 +195,7 @@ void shouldFailWhenLanguageTagAndLanguageIsSet() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailLanguageTagAndLanguage");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -204,7 +204,7 @@ void shouldFailWhenLanguageTagAndCountryIsSet() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailLanguageTagAndCountry");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -213,7 +213,7 @@ void shouldFailWhenLanguageTagAndVariantIsSet() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailLanguageTagAndVariant");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

}
Expand All @@ -227,8 +227,10 @@ class ClassLevel {
void shouldFailWhenVariantIsSetButCountryIsNot() {
ExecutionResults results = executeTestClass(ClassLevelInitializationFailureTestCase.class);

assertThat(results.numberOfFailedContainers()).isEqualTo(1);
assertThat(results.firstFailuresThrowable()).isInstanceOf(ExtensionConfigurationException.class);
assertThat(results)
.hasSingleContainer()
.thatFailed()
.withException(ExtensionConfigurationException.class);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

package org.junitpioneer.jupiter;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junitpioneer.jupiter.EnvironmentVariableExtension.WARNING_KEY;
import static org.junitpioneer.jupiter.EnvironmentVariableExtension.WARNING_VALUE;
import static org.junitpioneer.testkit.PioneerTestKit.executeTestClass;
import static org.junitpioneer.testkit.PioneerTestKit.executeTestMethod;
import static org.junitpioneer.testkit.assertion.PioneerAssert.EntryPoint.assertThat;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
Expand All @@ -23,6 +23,7 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionConfigurationException;
import org.junitpioneer.testkit.ExecutionResults;

@DisplayName("EnvironmentVariable extension")
Expand Down Expand Up @@ -209,7 +210,7 @@ void shouldFailWhenClearAndSetSameEnvironmentVariable() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailWhenClearAndSetSameEnvironmentVariable");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -221,7 +222,7 @@ void shouldFailWhenClearSameEnvironmentVariableTwice() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailWhenClearSameEnvironmentVariableTwice");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

@Test
Expand All @@ -230,7 +231,7 @@ void shouldFailWhenSetSameEnvironmentVariableTwice() {
ExecutionResults results = executeTestMethod(MethodLevelInitializationFailureTestCase.class,
"shouldFailWhenSetSameEnvironmentVariableTwice");

results.assertTestFailedWithExtensionConfigurationException();
assertThat(results).hasSingleTest().thatFailed().withException(ExtensionConfigurationException.class);
}

}
Expand All @@ -254,14 +255,14 @@ void shouldNotReportWarningIfExtensionNotUsed() {
void shouldReportWarningIfExtensionUsed() {
ExecutionResults results = executeTestMethod(ReportWarningTestCases.class, "testWithExtension");

assertThat(results.singleReportEntry()).isEqualTo(TestUtils.entryOf(WARNING_KEY, WARNING_VALUE));
assertThat(results).hasSingleReportEntry().withKeyAndValue(WARNING_KEY, WARNING_VALUE);
}

@Test
void shouldReportWarningExactlyOnce() {
ExecutionResults results = executeTestClass(ReportWarningTestCases.class);

assertThat(results.reportEntries()).hasSize(1);
assertThat(results).hasSingleReportEntry();
}

}
Expand Down