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.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
How to Use mica-boot-test for Spring Boot Unit Testing

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaGradlemavenunit testingSpring Boot
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.