1.项目名.iml文件
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
<orderEntry type="library" name="junit:junit:4.13" level="project" />
2.测试类
class StudentDao {
fun add() {
println("添加学生")
}
fun update() {
println("更新学生")
}
}
class StudentDaoTest {
companion object {
@BeforeClass
@JvmStatic
fun setUpBeforeClass() {
println("测试类执行之前。。。。。。。。。")
}
@AfterClass
@JvmStatic
fun tearDownAfterClass() {
println("测试类执行之后。。。。。。。。。")
}
}
@Before
fun setUp() {
println("方法之前执行........")
}
@After
fun tearDown() {
println("方法之后执行........")
}
@Test
fun test() {
println("测试方法")
}
@Test
fun test2() {
println("测试方法2")
}
@Test
fun testAdd() {
val studentDao = StudentDao()
studentDao.add()
}
@Test
fun testUpdate() {
val studentDao = StudentDao()
studentDao.update()
}
}