JUnit和TestNG允許為測(cè)試方法精密分組.
對(duì)于分組JUnit的測(cè)試類與測(cè)試方法,JUnit4.8引入了類別的概念.9該測(cè)試任務(wù)允許您設(shè)定JUnit包括或者排除某些類的規(guī)范。
例22.12.JUnit分類 build.gradle
test {
useJUnit {
includeCategories 'org.gradle.junit.CategoryA'
excludeCategories 'org.gradle.junit.CategoryB'
}
}
TestNG的框架有一個(gè)非常類似的概念。在TestNG的,你可以指定不同的測(cè)試組。 [10]測(cè)試分組應(yīng)包括或排除在測(cè)試任務(wù)進(jìn)行配置了的測(cè)試執(zhí)行.
例22.13.TestNG分組測(cè)試 build.gradle
test {
useTestNG {
excludeGroups 'integrationTests'
includeGroups 'unitTests'
}
}