hibernate - Junit with spring boot application -


i have application designed spring boot , hibernate completed. want use junit unit testing. should included in application.properties , need separate java file testing? working example or docs me getting started

include following dependency , spring boot configure testing.

<dependency>     <groupid>org.springframework.boot</groupid>     <artifactid>spring-boot-starter-test</artifactid>     <scope>test</scope> </dependency> 

after should able run tests src/test/java.

@runwith(springjunit4classrunner.class) @springapplicationconfiguration(classes = application.class) @webappconfiguration public class applicationtests {      @test     public void contextloads() {     }  } 

for data layer tests use @transactional on method or class. may create separate test class extending main test class. see below more options

@transactional public class datalayertest extends applicationtests{      @autowired     private leavedaoimpl daoimpl;      @test     // @transactional      // @rollback(true)     public void testfindall() {         // test here     }     } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -