Skip to content

Commit

Permalink
Support Serenity annotations on non-public test method (@title, @With…
Browse files Browse the repository at this point in the history
…Tag) #21

* upgrade to Serenity 2.3.9
  * Consider annotations on non-public test methods (TestAnnotations)
    * serenity-bdd/serenity-core#2306
  * Ignore stacktrace element for inner interfaces and inner or anonymous classes without a superclass (#2229) #2295
    * serenity-bdd/serenity-core#2295
    * >> removed previously added workaround
  • Loading branch information
fabianlinz committed Dec 8, 2020
1 parent de6bfed commit 8655a01
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 167 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logbackVersion = 1.2.3
serenityCoreVersion = 2.3.8
serenityCoreVersion = 2.3.9
junit5Version = 5.7.0
junitTestKitVersion = 1.7.0
assertJVersion = 3.13.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ void shouldHaveTwoSimpleTagsViaGroup() {
@Test
@Tag("junit5Tag")
@WithTag("serenityTag")
// TODO until https://github.com/fabianlinz/serenity-junit5/issues/21 is fixed Serenity tag annotation are only considered on public methods
public void shouldAllowUsageOfSerenityAndJunit5TagsTogether() {
void shouldAllowUsageOfSerenityAndJunit5TagsTogether() {
// does not make sense though
}

Expand All @@ -58,7 +57,7 @@ void junit5FeatureTag() {

@Test
@WithTag(name = "serenityFeatureTag")
public void serenityFeatureTag() {
void serenityFeatureTag() {
// does not make sense though
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package starter;

import net.serenitybdd.junit5.SerenityTest;
import net.thucydides.core.annotations.Manual;
import net.thucydides.core.model.TestResult;
import net.thucydides.core.annotations.Title;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assumptions.assumeTrue;
Expand All @@ -27,4 +26,9 @@ void successfulTest() {
assumeTrue(true);
}

@Test
@Title("An explicit title for the test.")
void testWithTitle() {

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ static class UsageOfSerenityAndJunit5TagsTogether {
@WithTag("serenityTag"),
@WithTag(name = "serenityFeatureTag")
})
// TODO until https://github.com/fabianlinz/serenity-junit5/issues/21 is fixed Serenity tag annotation are only considered on public methods
public void test() {
void test() {
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.serenitybdd.junit5.extension;

import net.serenitybdd.junit5.extension.testsupport.SerenityExtensionInnerTest;
import net.serenitybdd.junit5.extension.testsupport.SerenityExtensionTest;
import net.thucydides.core.annotations.Steps;
import net.thucydides.core.annotations.Title;
import org.junit.jupiter.api.Test;

@SerenityExtensionTest
class WhenRunningTitleTests {

@Steps
private JUnit5Steps junit5;

@Test
void the_outcome_should_honor_the_declared_title() {
// when
junit5.executesTestClass(TestWithTitle.class);

// then
junit5.shouldHaveExactlyOneTestOutcome();
junit5.outcomeShouldHaveTitle("explicit test title");
}

@SerenityExtensionInnerTest
static class TestWithTitle {
@Test
@Title("explicit test title")
void testWithTitle() {
}
}
}

0 comments on commit 8655a01

Please sign in to comment.