How to Use mica-boot-test for Spring Boot Unit Testing
This guide explains the purpose of the mica-boot-test component, shows how to add its Maven or Gradle dependency, and provides two example test classes demonstrating the use of @MicaBootTest with either @RunWith(MicaSpringRunner.class) or inheritance from MicaBaseTest.
mica-boot-test Test Component
Introduction
Because we embed some configuration in the mica-launcher component, this component is provided for convenient unit testing.
Dependency Coordinates
Maven
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-boot-test</artifactId>
<scope>test</scope>
</dependency>Gradle
testCompile "net.dreamlu:mica-boot-test"Usage
Example Code 1
Use @RunWith(MicaSpringRunner.class).
@SpringBootTest
@MicaBootTest("appName")
@RunWith(MicaSpringRunner.class)
public class MicaExampleApplicationTests {
@Test
public void contextLoads() {
}
}Example Code 2
Extend MicaBaseTest.
@SpringBootTest
@MicaBootTest("appName")
public class ApplicationTests extends MicaBaseTest {
@Test
public void contextLoads() {
}
}Both approaches are valid. The @MicaBootTest annotation has attributes for service name, profile, and enableLoader.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
