TestNG
TestNG在springboot中的简单使用
引入依赖
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.10</version>
<scope>test</scope>
</dependency>
简单使用
@SpringBootTest
/**
* AbstractTestNGSpringContextTests:测试类只有继承了该类才能拥有注入实例能力,否则注入报错
* AbstractTransactionalTestNGSpringContextTests:测试类继承该类后拥有注入实例能力,同时拥有事物控制能力
* ***/
public class UserAndBlogTest extends AbstractTestNGSpringContextTests {
@Autowired
private UserAndBlog userAndBlog;
@Test
public void testGetBlogByName() {
System.out.println(userAndBlog.getBlogByName("markerhub"));
}
}
自动生成xml文件
Intellij IDEA->Preferences->Plugins->搜索安装“Create TestNG XML”
安装后重启IDEA
根目录右键即可看到“Create TestNG XML”选项,点击后生成“testng.xml”文件。
但是生成的文件没有自动格式化
格式化xml文件
option+command+L