Class DbUnitJunitRunner

  • All Implemented Interfaces:
    org.junit.runner.Describable, org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Orderable, org.junit.runner.manipulation.Sortable

    public class DbUnitJunitRunner
    extends org.junit.runners.BlockJUnit4ClassRunner
    Implementation of JUnit Runner to fill and clear database between each tests.
    Basically, this class add DbUnitRule to the test class when this runner is initialized.
    DbUnit configuration should be set using DbUnitConnection configuration:
    
    
       @RunWith(DbUnitJunitRunner.class)
       @DbUnitConnection(url = "jdbc:hsqldb:mem:testdb", user = "SA", password = "")
       @bUnitDataSet("classpath:/dataset/xml")
       public class MyDaoTest {
         @Test
         public void test1() {
           // ...
         }
       }
    
     
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected List<org.junit.rules.TestRule> getTestRules​(Object target)  
      • Methods inherited from class org.junit.runners.BlockJUnit4ClassRunner

        collectInitializationErrors, computeTestMethods, createTest, createTest, describeChild, getChildren, isIgnored, methodBlock, methodInvoker, possiblyExpectingExceptions, rules, runChild, testName, validateConstructor, validateFields, validateInstanceMethods, validateNoNonStaticInnerClass, validateOnlyOneConstructor, validateTestMethods, validateZeroArgConstructor, withAfters, withBefores, withPotentialTimeout
      • Methods inherited from class org.junit.runners.ParentRunner

        childrenInvoker, classBlock, classRules, createTestClass, filter, getDescription, getName, getRunnerAnnotations, getTestClass, order, run, runLeaf, setScheduler, sort, validatePublicVoidNoArgMethods, withAfterClasses, withBeforeClasses, withInterruptIsolation
      • Methods inherited from class org.junit.runner.Runner

        testCount
    • Constructor Detail

      • DbUnitJunitRunner

        public DbUnitJunitRunner​(Class<?> klass)
                          throws org.junit.runners.model.InitializationError
        Create runner.
        Parameters:
        klass - Running class.
        Throws:
        org.junit.runners.model.InitializationError - If an error occurred while creating Jdbc connection factory.
    • Method Detail

      • getTestRules

        protected List<org.junit.rules.TestRule> getTestRules​(Object target)
        Overrides:
        getTestRules in class org.junit.runners.BlockJUnit4ClassRunner