Search in sources :

Example 1 with SeleniumTestsReporter2

use of com.seleniumtests.reporter.reporters.SeleniumTestsReporter2 in project seleniumRobot by bhecquet.

the class TestBugTracker method testCreateIssueBean.

/**
 * Create a new issue bean
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateIssueBean() throws Exception {
    // copy resources so that we can be sure something has been copied to zip file
    new SeleniumTestsReporter2().copyResources();
    FakeBugTracker fbt = spy(new FakeBugTracker());
    PowerMockito.whenNew(FakeBugTracker.class).withAnyArguments().thenReturn(fbt);
    BugTracker bugtracker = BugTracker.getInstance("fake", "http://foo/bar", "selenium", "user", "password", new HashMap<>());
    IssueBean issueBean = bugtracker.createIssueBean("[Selenium][selenium][DEV][ngName] test myTest KO", "testCreateIssueBean", "some description", Arrays.asList(step1, step2, stepEnd), issueOptions);
    Assert.assertEquals(issueBean.getAssignee(), "me");
    Assert.assertEquals(issueBean.getDescription(), "Test: testCreateIssueBean\n" + "Description: some description\n" + "Error step 1 (step 2): java.lang.NullPointerException: Error clicking\n" + "\n" + "Steps in error\n" + "Step 1: step 2\n" + "------------------------------------\n" + "Step step 2\n" + "  - action1\n" + "  - action2\n" + "\n" + "Last logs\n" + "Step Test end\n" + "\n" + "For more details, see attached .zip file");
    Assert.assertEquals(issueBean.getSummary(), "[Selenium][selenium][DEV][ngName] test myTest KO");
    Assert.assertEquals(issueBean.getReporter(), "you");
    Assert.assertEquals(issueBean.getTestName(), "testCreateIssueBean");
    // screenshots from the last step
    Assert.assertEquals(issueBean.getScreenShots(), Arrays.asList(screenshot, screenshot));
    // we take the last failing step (not Test end)
    Assert.assertEquals(issueBean.getTestStep(), step2);
    Assert.assertEquals(issueBean.getDateTime().getDayOfMonth(), ZonedDateTime.now().plusHours(3).getDayOfMonth());
    Assert.assertTrue(issueBean.getDetailedResult().isFile());
    Assert.assertEquals(issueBean.getDetailedResult().getName(), "detailedResult.zip");
    Assert.assertTrue(issueBean.getDetailedResult().length() > 900000);
    // not initialized by default
    Assert.assertNull(issueBean.getId());
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) SeleniumTestsReporter2(com.seleniumtests.reporter.reporters.SeleniumTestsReporter2) BugTracker(com.seleniumtests.connectors.bugtracker.BugTracker) FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

MockitoTest (com.seleniumtests.MockitoTest)1 BugTracker (com.seleniumtests.connectors.bugtracker.BugTracker)1 FakeBugTracker (com.seleniumtests.connectors.bugtracker.FakeBugTracker)1 IssueBean (com.seleniumtests.connectors.bugtracker.IssueBean)1 SeleniumTestsReporter2 (com.seleniumtests.reporter.reporters.SeleniumTestsReporter2)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 Test (org.testng.annotations.Test)1