/** Test run one Test successfully. */
  @Test
  public void testRunsSuccessfully() {
    TestProtocolService protocolService = new TestProtocolService();
    TestCase testCase = new TestCase();
    testCase.setName("TestCase1");
    protocolService.set(testCase, new TestResult());

    TestResult testResult = protocolService.get(testCase);

    assertNotNull(testResult);
    assertTrue(!testResult.isSuccessfully());
  }
 /**
  * Test the Remove of Tests and Test by name. Changing a Testcase in an Editor should remove the
  * testcase from the TestProtocolService to indicate, that the changed test is'nt run yet.
  */
 @Test
 public void testRemoveChangedTestCaseFromProtocol() {
   TestProtocolService protocolService = new TestProtocolService();
   TestCase testCase = new TestCase();
   testCase.setName("TestCase1");
   protocolService.set(testCase, new TestResult());
   assertNotNull("Expecting a testcase on the protocol service.", protocolService.get(testCase));
   protocolService.remove(testCase);
   assertNull(
       "Expecting that the testcase is removed from  the protocol service.",
       protocolService.get(testCase));
 }
  /** Test was never run before. */
  @Test
  public void testNeverRuns() {

    TestResult testResult = new TestResult();
    testResult.setWrong(1);

    TestCase testCase = new TestCase();
    testCase.setName("TestCase3");

    testResult = new TestProtocolService().get(testCase);

    assertNull(testResult);
  }
  /** Tests the Registration of an Event Hanlder in the event broker of the eclpse context. */
  @Test
  public void testEventBrokerEventHanlderRegistration() {
    TestProtocolService protocolService = new TestProtocolService();
    IEclipseContext context = EclipseContextFactory.create();
    final Map<String, EventHandler> topics = new HashMap<String, EventHandler>();
    context.set(
        IEventBroker.class,
        new IEventBroker() {

          @Override
          public boolean send(String topic, Object data) {
            return false;
          }

          @Override
          public boolean post(String topic, Object data) {
            return false;
          }

          @Override
          public boolean subscribe(String topic, EventHandler eventHandler) {
            topics.put(topic, eventHandler);
            return true;
          }

          @Override
          public boolean subscribe(
              String topic, String filter, EventHandler eventHandler, boolean headless) {
            return false;
          }

          @Override
          public boolean unsubscribe(EventHandler eventHandler) {
            return false;
          }
        });
    protocolService.compute(context, null);
    EventHandler handler =
        topics.get(TestEditorCoreEventConstants.TESTSTRUCTURE_MODEL_CHANGED_DELETED);
    assertNotNull("Hanlder should be registered", handler);
    TestCase testCase = new TestCase();
    testCase.setName("TestCase1");
    protocolService.set(testCase, new TestResult());
    assertNotNull(protocolService.get(testCase));
    Map<String, String> properties = new HashMap<String, String>();
    properties.put("org.eclipse.e4.data", testCase.getFullName());
    Event event =
        new Event(TestEditorCoreEventConstants.TESTSTRUCTURE_MODEL_CHANGED_DELETED, properties);
    handler.handleEvent(event);
    assertNull(protocolService.get(testCase));
  }
 /** Test Protocol on execute a TestSuite that contains referred Testcases. */
 @Test
 public void testRunSuiteWithReferedTestCases() {
   TestProtocolService protocolService = new TestProtocolService();
   TestResult testResult = new TestResult();
   TestResult tcTestResult = new TestResult();
   tcTestResult.setFullName("MyName");
   testResult.add(tcTestResult);
   TestSuite testSuite = new TestSuite();
   protocolService.set(testSuite, testResult);
   assertNotNull(protocolService.get(testSuite));
   TestCase testCase = new TestCase();
   testCase.setName("MyName");
   testSuite.addReferredTestStructure(testCase);
   assertNotNull(protocolService.get(testCase));
 }
 /** Test Protocol on execute a TestSuite that has Children. */
 @Test
 public void testRunSuiteWithChildren() {
   TestProtocolService protocolService = new TestProtocolService();
   TestCase testCase = new TestCase();
   testCase.setName("MyName");
   TestSuite testSuite = new TestSuite();
   testSuite.addChild(testCase);
   TestResult testResult = new TestResult();
   TestResult tcTestResult = new TestResult();
   tcTestResult.setFullName(testCase.getFullName());
   testResult.add(tcTestResult);
   assertTrue(testResult.isSuite());
   protocolService.set(testSuite, testResult);
   assertNotNull(protocolService.get(testSuite));
   assertNotNull(protocolService.get(testCase));
 }
  /** Test run one Test not successfully. */
  @Test
  public void testRunsNotSuccessfully() {
    TestProtocolService protocolService = new TestProtocolService();
    TestResult testResult = new TestResult();
    testResult.setException(0);
    testResult.setIgnored(0);
    testResult.setRight(0);
    testResult.setWrong(1);

    TestCase testCase = new TestCase();
    testCase.setName("TestCase2");
    protocolService.set(testCase, testResult);

    testResult = protocolService.get(testCase);

    assertNotNull(testResult);
    assertFalse(testResult.isSuccessfully());
  }
Exemplo n.º 8
0
 /**
  * Tests the lookup of a TestStructure based on a relative path name. Path Name like:
  * /DemoWebRapTests/DialogWidgetsSuite/ConfirmMessageTest
  *
  * @throws SystemException for test
  */
 @Test
 public void testLookUpOfTestStructure() throws SystemException {
   TestProject project = new TestProject();
   project.setName("DemoWebRapTests");
   TestSuite suite = new TestSuite();
   project.addChild(suite);
   suite.setName("DialogWidgetsSuite");
   TestCase testCase = new TestCase();
   testCase.setName("ConfirmMessageTest");
   suite.addChild(testCase);
   TeamChange change =
       new TeamChange(
           TeamChangeType.DELETE,
           "DemoWebRapTests.DialogWidgetsSuite.ConfirmMessageTest",
           project);
   TestStructure testStructure = change.getReleatedTestStructure();
   assertNotNull("TestStructure expected.", testStructure);
   assertEquals(
       "Expecting MyTestCase as teststructure", "ConfirmMessageTest", testStructure.getName());
 }