Skip to content

Commit

Permalink
(test) Adding functional test for repo flaky tests (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
craigatk authored Oct 1, 2020
1 parent f3c194e commit ddb5153
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"groupedTestSuites": [
{
"groupName": "Group1",
"groupLabel": "unitTest",
"directory": "/test/unit",
"testSuitesBlob": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<testsuite name=\"projektor.example.spock.FailingSpec\" tests=\"2\" skipped=\"0\" failures=\"2\" errors=\"0\" timestamp=\"2019-10-01T13:15:44\" hostname=\"Craigs-MacBook-Pro.local\" time=\"0.125\">\r\n <properties/>\r\n <testcase name=\"should fail\" classname=\"projektor.example.spock.FailingSpec\" time=\"0.119\">\r\n <failure message=\"Condition not satisfied:&#10;&#10;1 == 2&#10; |&#10; false&#10;\" type=\"org.spockframework.runtime.SpockComparisonFailure\">Condition not satisfied:\r\n\r\n1 == 2\r\n |\r\n false\r\n\r\n\tat projektor.example.spock.FailingSpec.should fail(FailingSpec.groovy:8)\r\n</failure>\r\n </testcase>\r\n <testcase name=\"should fail with output\" classname=\"projektor.example.spock.FailingSpec\" time=\"0.006\">\r\n <failure message=\"Condition not satisfied:&#10;&#10;actual == 3&#10;| |&#10;1 false&#10;\" type=\"org.spockframework.runtime.SpockComparisonFailure\">Condition not satisfied:\r\n\r\nactual == 3\r\n| |\r\n1 false\r\n\r\n\tat projektor.example.spock.FailingSpec.should fail with output(FailingSpec.groovy:22)\r\n</failure>\r\n </testcase>\r\n <system-out><![CDATA[A line in the given block\r\nAnother line in the given block\r\nA line in the when block\r\nA line in the then block\r\n]]></system-out>\r\n <system-err><![CDATA[]]></system-err>\r\n</testsuite>\r\n"
}
],
"metadata": {
"git": {
"repoName": "flaky-org/flaky-repo",
"branchName": "main",
"projectName": null,
"isMainBranch": true
},
"ci": true
},
"wallClockDuration": null
}
45 changes: 45 additions & 0 deletions functional-test/cypress/integration/repository_flaky_tests.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/// <reference types="Cypress" />

context("repository timeline", () => {
it("displays flaky tests in repository", () => {
const orgPart = Math.random().toString(36).substr(2, 7);
const repoPart = "flaky-tests-repo";
const repoName = `${orgPart}/${repoPart}`;

cy.readFile("cypress/fixtures/grouped-failing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
}
);

cy.readFile("cypress/fixtures/grouped-failing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
}
);

cy.readFile("cypress/fixtures/grouped-failing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
}
);

cy.getByTestId("nav-link-repository").click(); // From the test run page

cy.getByTestId("nav-link-repo-flaky-tests").click(); // From the repo page

cy.getByTestId("repository-flaky-tests-table");

cy.getByTestId("flaky-test-case-name-1").should(
"contain",
"projektor.example.spock.FailingSpec"
);
cy.getByTestId("flaky-test-case-failure-count-1").should("contain", "3");
});
});
44 changes: 22 additions & 22 deletions functional-test/cypress/integration/repository_timeline.spec.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
/// <reference types="Cypress" />

context("repository timeline", () => {
it("displays test run over time for the repository", () => {
const orgPart = Math.random().toString(36).substr(2, 7);
const repoPart = "timeline-repo";
const repoName = `${orgPart}/${repoPart}`;
it("displays test run over time for the repository", () => {
const orgPart = Math.random().toString(36).substr(2, 7);
const repoPart = "timeline-repo";
const repoName = `${orgPart}/${repoPart}`;

cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;
cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
}
);
cy.loadGroupedFixtureData(resultsBlob, "");
}
);

cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;
cy.readFile("cypress/fixtures/grouped-passing-tests-with-git.json").then(
(resultsBlob) => {
resultsBlob.metadata.ci = true;
resultsBlob.metadata.git.repoName = repoName;

cy.loadGroupedFixtureData(resultsBlob, "");
}
);
cy.loadGroupedFixtureData(resultsBlob, "");
}
);

cy.getByTestId("nav-link-repository").click(); // From the test run page
cy.getByTestId("nav-link-repository").click(); // From the test run page

cy.getByTestId("nav-link-repo-timeline").click(); // From the repo page
cy.getByTestId("nav-link-repo-timeline").click(); // From the repo page

cy.getByTestId("repository-timeline-graph");
});
cy.getByTestId("repository-timeline-graph");
});
});

0 comments on commit ddb5153

Please sign in to comment.