Search in sources :

Example 1 with FakeBugTracker

use of com.seleniumtests.connectors.bugtracker.FakeBugTracker 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)

Example 2 with FakeBugTracker

use of com.seleniumtests.connectors.bugtracker.FakeBugTracker in project seleniumRobot by bhecquet.

the class TestBugTracker method testCreateIssueBeanWithStepDisabled.

/**
 * Test that if the failed step disables bugtracker, but an other keeps it enabled, the issue bean is created
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateIssueBeanWithStepDisabled() throws Exception {
    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", "testCreateIssueBeanWithStepDisabled", "some description", Arrays.asList(step1, step2, stepFailedWithDisabledBugtracker, stepEnd), issueOptions);
    Assert.assertNotNull(issueBean);
    // check description only points step2 as the failed step
    Assert.assertEquals(issueBean.getDescription(), "Test: testCreateIssueBeanWithStepDisabled\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");
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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)

Example 3 with FakeBugTracker

use of com.seleniumtests.connectors.bugtracker.FakeBugTracker in project seleniumRobot by bhecquet.

the class TestBugTracker method testCreateIssue.

/**
 * Create a new issue when there is a failed step
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateIssue() throws Exception {
    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<>());
    bugtracker.createIssue("selenium", "DEV", "ngName", "testCreateIssue", "some description", Arrays.asList(step2, stepEnd), issueOptions);
    // check that we check if the issue already exists
    verify(fbt).issueAlreadyExists(any(IssueBean.class));
    // check that issue is created
    verify(fbt).createIssue(any(IssueBean.class));
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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)

Example 4 with FakeBugTracker

use of com.seleniumtests.connectors.bugtracker.FakeBugTracker in project seleniumRobot by bhecquet.

the class TestBugTracker method testUpdateIssue.

/**
 * Update an existing issue as we fail on an other step
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testUpdateIssue() throws Exception {
    FakeBugTracker fbt = spy(new FakeBugTracker());
    PowerMockito.whenNew(FakeBugTracker.class).withAnyArguments().thenReturn(fbt);
    when(fbt.issueAlreadyExists(any(IssueBean.class))).thenReturn(new IssueBean("ISSUE-1", "[Selenium][app][env][ng] test Test1 KO", "Test KO"));
    BugTracker bugtracker = BugTracker.getInstance("fake", "http://foo/bar", "selenium", "user", "password", new HashMap<>());
    bugtracker.createIssue("selenium", "DEV", "ngName", "testUpdateIssue", "some description", Arrays.asList(step1, step2, stepEnd), issueOptions);
    // check that we check if the issue already exists
    verify(fbt).issueAlreadyExists(any(IssueBean.class));
    // check that issue is not created
    verify(fbt, never()).createIssue(any(IssueBean.class));
    verify(fbt).updateIssue(eq("ISSUE-1"), anyString(), anyList(), eq(step2));
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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)

Example 5 with FakeBugTracker

use of com.seleniumtests.connectors.bugtracker.FakeBugTracker in project seleniumRobot by bhecquet.

the class TestBugTracker method testCreateIssueBeanNoStep.

/**
 * If no steps are available, do not create IssueBean
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCreateIssueBeanNoStep() throws Exception {
    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", "myTest", "some description", new ArrayList<>(), issueOptions);
    Assert.assertNull(issueBean);
}
Also used : FakeBugTracker(com.seleniumtests.connectors.bugtracker.FakeBugTracker) IssueBean(com.seleniumtests.connectors.bugtracker.IssueBean) 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)9 BugTracker (com.seleniumtests.connectors.bugtracker.BugTracker)9 FakeBugTracker (com.seleniumtests.connectors.bugtracker.FakeBugTracker)9 IssueBean (com.seleniumtests.connectors.bugtracker.IssueBean)9 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 Test (org.testng.annotations.Test)9 SeleniumTestsReporter2 (com.seleniumtests.reporter.reporters.SeleniumTestsReporter2)1