-
Notifications
You must be signed in to change notification settings - Fork 346
UI tests of #342 without structural folder changes #355
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
Conversation
Bumps [database](https://github.com/jenkinsci/database-plugin) from 117.va2009e38b882 to 128.vaa83e142f7f2. - [Release notes](https://github.com/jenkinsci/database-plugin/releases) - [Commits](https://github.com/jenkinsci/database-plugin/commits) --- updated-dependencies: - dependency-name: org.jenkins-ci.plugins:database dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts: # pom.xml
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
# Conflicts: # pom.xml
|
|
||
| JUnitBuildSummary buildSummary = new JUnitBuildSummary(build); | ||
|
|
||
| assertThat(buildSummary.getTitleText()).containsAnyOf("no failures", "0 failures"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to split the title into the link and the text in the brackets and check both of them
| JUnitBuildSummary buildSummary = new JUnitBuildSummary(build); | ||
|
|
||
| assertThat(buildSummary.getTitleText()).containsAnyOf("no failures", "0 failures"); | ||
| assertThat(buildSummary.getFailureNames()).isEmpty(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the generated assertions:
| assertThat(buildSummary.getFailureNames()).isEmpty(); | |
| assertThat(buildSummary).hasNoFailureNames(); |
| assertThat(buildSummary.getFailureNames()) | ||
| .containsExactlyInAnyOrder("JUnit.testScore[0]", "JUnit.testScore[1]", "JUnit.testScore[2]", "TestNG.testScore", "TestNG.testScore", "TestNG.testScore"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the build summary supports navigation using links, it would be helpful to check these as well (and navigate to the detail pages)
| assertThat(buildTestResultsByClass.getTestTableEntries()).extracting(List::size).isEqualTo(2); | ||
|
|
||
| TestUtils.assertElementInCollection(buildTestResultsByClass.getTestTableEntries(), | ||
| testTableEntry -> testTableEntry.getTestName().equals("testAppFailNoMessage"), | ||
| testTableEntry -> testTableEntry.getTestName().equals("testAppFailNoStacktrace")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AssertJ is your friend, make usage of the API:
assertThat(buildTestResultsByClass.getTestTableEntries())
.hasSize(2)
.extracting(TestTableEntry::getTestName)
.containsExactly("testAppFailNoMessage", "testAppFailNoStacktrace");
Seems that your import is wrong (in all tests!), you need to import
import static io.jenkins.plugins.analysis.junit.Assertions.*;
| .openTestResultsByClass("ApplicationTest"); | ||
|
|
||
| TestUtils.assertElementInCollection(buildTestResultsByClass.getTestTableEntries(), | ||
| tableEntry -> tableEntry.getTestName().equals("testAppFail") && tableEntry.getStatus().equals("Failed"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use AssertJ features
| * @param predicates assertion criteria | ||
| * @param <E> the type of elements in this collection | ||
| */ | ||
| public static <E> void assertElementInCollection(Collection<E> collection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should work out of the box with standard AssertJ
| */ | ||
| public class BuildChartEntry { | ||
|
|
||
| final int buildId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fields must be private.
| WebElement mainPanel = getElement(By.cssSelector("#main-panel")); | ||
| packageLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel); | ||
| packageTableEntries = initializePackageTableEntries(mainPanel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract duplicate code into method
| WebElement mainPanel = getElement(By.cssSelector("#main-panel")); | ||
| testLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel); | ||
| testTableEntries = initializeTestTableEntries(mainPanel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract duplicate code into method
| WebElement mainPanel = getElement(By.cssSelector("#main-panel")); | ||
| classLinks = TestResultsTableUtil.getLinksOfTableItems(mainPanel); | ||
| classTableEntries = initializeClassTableEntries(mainPanel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extract duplicate code into method
See #342.
The first two commits have been moved to a separate branch so that GitHub UI will not freeze during reviews anymore.