Package junit.framework

Examples of junit.framework.JUnit4TestAdapter


    junit.framework.Test test= adapter.getTests().get(0);
    assertEquals(String.format("test(%s)", NewTest.class.getName()), test.toString());
  }

  public void testUseGlobalCache() {
    JUnit4TestAdapter adapter1= new JUnit4TestAdapter(NewTest.class);
    JUnit4TestAdapter adapter2= new JUnit4TestAdapter(NewTest.class);
    assertSame(adapter1.getTests().get(0), adapter2.getTests().get(0));
  }
View Full Code Here


      throw exception;
    }
  }
  public void testException() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(ErrorTest.class);
    adapter.run(result);
    assertEquals(exception, result.errors().nextElement().thrownException());
  }
View Full Code Here

    adapter.run(result);
    assertEquals(exception, result.errors().nextElement().thrownException());
  }
 
  public void testNotifyResult() {
    JUnit4TestAdapter adapter= new JUnit4TestAdapter(ErrorTest.class);
    TestResult result= new TestResult();
    final StringBuffer log= new StringBuffer();
    result.addListener(new TestListener() {
   
      public void startTest(junit.framework.Test test) {
        log.append(" start " + test);
      }
   
      public void endTest(junit.framework.Test test) {
        log.append(" end " + test);
      }
   
      public void addFailure(junit.framework.Test test, AssertionFailedError t) {
        log.append(" failure " + test);   
      }
   
      public void addError(junit.framework.Test test, Throwable t) {
        log.append(" error " + test);   
      }
    });
    adapter.run(result);
    String testName= String.format("error(%s)", ErrorTest.class.getName());
    assertEquals(String.format(" start %s error %s end %s", testName, testName, testName), log.toString());
  }
View Full Code Here

    @Test(expected=Exception.class) public void succeed() throws Exception {
    }
  }
  public void testNoException() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(NoExceptionTest.class);
    adapter.run(result);
    assertFalse(result.wasSuccessful());
  }
View Full Code Here

      throw new Exception();
    }
  }
  public void testExpected() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(ExpectedTest.class);
    adapter.run(result);
    assertTrue(result.wasSuccessful());
  }
View Full Code Here

  }
 
  public void testBeforeAndAfterClass() {
    log= "";
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(BeforeClassTest.class);
    adapter.run(result);
    assertEquals("before class before test after before test after after class ", log);
  }
View Full Code Here

    }
  }
 
  public void testExceptionInBefore() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(ExceptionInBeforeTest.class);
    adapter.run(result);
    assertEquals(1, result.errorCount());
  }
View Full Code Here

    @BeforeClass public void shouldBeStatic() {}
  }
 
  public void testInvalidMethod() {
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(InvalidMethodTest.class);
    adapter.run(result);
    assertEquals(1, result.errorCount())
    TestFailure failure= result.errors().nextElement();
    assertTrue(failure.exceptionMessage().contains("Method shouldBeStatic() should be static"));
  }
View Full Code Here

  }
 
  public void testRunWithClass() {
    wasRun= false;
    TestResult result= new TestResult();
    junit.framework.Test adapter= new JUnit4TestAdapter(NoTests.class);
    adapter.run(result);
    assertTrue(wasRun);
  }
View Full Code Here

    adapter.run(result);
    assertTrue(wasRun);
  }
 
  public void testToStringSuite() {
    junit.framework.Test adapter= new JUnit4TestAdapter(NoTests.class);
    assertEquals(NoTests.class.getName(), adapter.toString());
  }
View Full Code Here

TOP

Related Classes of junit.framework.JUnit4TestAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.