如何执行mybatis-spring-boot-starter-test?

How to execute mybatis-spring-boot-starter-test?

对于mybatis-spring-boot-starter-test I see no main method and even no Java file. It has two dependencies of which mybatis-spring-boot-test-autoconfigure contains some test files and I can execute them while spring-boot-starter-test只有一个pom文件。

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

那么如何执行这些测试模块呢?不可以,它是为了什么而创造的?

此模块不适用于 "execution"。看看 their docs:

What is MyBatis-Spring-Boot-Starter-Test?

The MyBatis-Spring-Boot-Starter-Test help creating a test cases for MyBatis component using the MyBatis-Spring-Boot-Starter.

By using this module you will can be:

  • Can use the @MybatisTest that setup test components for testing pure MyBatis component
  • Can import dependency artifacts for performing tests for pure MyBatis component

所以,这个模块 provides you @MybatisTest from mybatis-spring-boot-test-autoconfigure。基本上,这就是 "starters" 是什么:一组(可能是一个,就像在这种情况下)旨在协同工作以提供某些功能的依赖项。

Read more关于使用@MybatisTest.