Skip to content

Commit

Permalink
How to use @SpringBootTest on my library submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
slem1 committed Oct 31, 2017
1 parent 191eee5 commit ffd8316
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spring-boot-test-howto-business/pom.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@
<groupId>fr.sle</groupId> <groupId>fr.sle</groupId>
<artifactId>spring-boot-test-howto-business</artifactId> <artifactId>spring-boot-test-howto-business</artifactId>


<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

</dependencies>


</project> </project>
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,10 @@
package fr.sle.testhowto;

import org.springframework.stereotype.Component;

/**
* @author slemoine
*/
@Component
public class MyComponent {
}
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,10 @@
package fr.sle.testhowto;

import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author slemoine
*/
@SpringBootApplication
public class ApplicationTest {
}
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,24 @@
package fr.sle.testhowto.test;

import fr.sle.testhowto.MyComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
* @author slemoine
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class MyComponentTestClass {

@Autowired
private MyComponent component;

@Test
public void myComponentTestMethod(){

}
}

0 comments on commit ffd8316

Please sign in to comment.