一. TestNG相关jar软件包引用1,添加到pom.xml文件中:
! - -与-- testNG相关的jar包参考----dependencygroupidorg.TestNG/groupidartifactidtestng/artifactidversion6. 14.3/versiong 基于SpringBoot框架的测试文件引入基本标签1,SpringBoot引入以下依赖关系。 版本最好与项目中使用的Spring版本匹配。
部署springboot :
ependencygroupidorg.spring framework.boot/groupidartifactidspring-boot-test/artifact id/dependency 2,…/src/mm
打开此主类以验证以下内容:
@ springbootapplication @ mappers can (com.nuonuo.nnjf.financing.mapper ) )。 @ enableeurekaclient @ enablefeignclientspublicclassfinancingmain { publicstaticvoidmain { string [ ] args } throws exception { 必须指定启动类。
@runwith(springrunner.class ) springboottest ) classes=financingmain.class ) /启动系统publiccclassapplicationtestextent { @ autowiredprivateproductcontrollerproductcontroller; @test(publicvoidtest ) throwsexception ) system.out.println ) ' Helloworld!' ); @test(publicvoidtest ) throwsexception ) system.out.println ('产品列' productController.getXX ) ); }注意:
)1)引用了Junit的@Test,import org.junit.Test; 不需要继承AbstractTestNGSpringContextTests类
)2)如果使用TestNG框架,则importorg.TestNG.annotations.test; 创建测试类时,继承AbstractTestNGSpringContextTests类
)3) Spring2.5及更高版本支持测试。 org.spring framework.test.context.Testng包为基于TestNG的测试用例提供支持类。
1、abstracttestngspringcontexttests
抽象出了集成了Spring TestContext Framework和TestNG环境下应用程序上下文测试支持的基础测试类。 如果明智的笔继承abstracttestngspringcontexttests,则可以访问以下protected成员变量: 应用程序上下文:使用它来测试显式bean搜索或上下文的整体状态。