Micronaut Test

Micronaut 测试相关实用程序资源库。Micronaut Framework 是一个基于 JVM 的现代全栈 Java 框架。「Repository for Test Related Utilities for Micronaut. Micronaut Framework is a modern, JVM-based, full stack Java framework.」

  • 所有者: micronaut-projects/micronaut-test
  • 平台: Windows,Linux,Mac
  • 許可證: Apache License 2.0
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

Spock: Maven Central
JUnit 5: Maven Central
Kotest: Maven Central
Kotest 5: Maven Central
Quality Gate Status

Micronaut Test

This project provides testing extension for JUnit 5, Spock and Kotest to make it easier to test Micronaut applications.

For more information see the Latest or Snapshot Documentation.

Example Spock Test:

import io.micronaut.test.annotation.MicronautTest
import spock.lang.*
import jakarta.inject.Inject

@MicronautTest // Declares the test as a micronaut test
class MathServiceSpec extends Specification {

    @Inject
    MathService mathService // Dependency injection is used to supply the system under test

    @Unroll
    void "should compute #num times 4"() { // This is the test case. #num will be replaces by the values defined in the where: block
        when:
        def result = mathService.compute(num)

        then:
        result == expected

        where:
        num | expected
        2   | 8
        3   | 12
    }
}

Example JUnit 5 Test:

import io.micronaut.test.annotation.MicronautTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import jakarta.inject.Inject;


@MicronautTest // Declares the test as a micronaut test
class MathServiceTest {

    @Inject
    MathService mathService; // Dependency injection is used to supply the system under test


    @ParameterizedTest
    @CsvSource({"2,8", "3,12"})
    void testComputeNumToSquare(Integer num, Integer square) {
        final Integer result = mathService.compute(num); // Injected bean can be used in test case

        Assertions.assertEquals(
                square,
                result
        );
    }
}

Snapshots and Releases

Snaphots are automatically published to JFrog OSS using Github Actions.

See the documentation in the Micronaut Docs for how to configure your build to use snapshots.

Releases are published to JCenter and Maven Central via Github Actions.

A release is performed with the following steps:

主要指標

概覽
名稱與所有者micronaut-projects/micronaut-test
主編程語言Java
編程語言Java (語言數: 3)
平台
許可證Apache License 2.0
所有者活动
創建於2018-09-28 16:07:55
推送於2025-04-18 20:29:37
最后一次提交
發布數91
最新版本名稱v4.7.0 (發布於 2025-02-07 11:51:15)
第一版名稱v1.0.0.M1 (發布於 )
用户参与
星數86
關注者數16
派生數62
提交數1.2k
已啟用問題?
問題數210
打開的問題數54
拉請求數763
打開的拉請求數22
關閉的拉請求數222
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?