Tag: testng

在使用@Retention,@Transactional,@Inherited进行注释服务的testing之后,TestNGunit testing不起作用

我正在testing一个商业服务与TestNG,在春季启动应用程序的mockitounit testing。 应用程序是多模块弹簧引导项目。我正在为业务模块编写unit testing。 我已经在pom中添加了以下相关性testing, <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>${testng.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>javax.el</groupId> <artifactId>el-api</artifactId> <version>${javaxel.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.glassfish</groupId> <artifactId>javax.servlet</artifactId> <version>${javax.servlet.version}</version> <scope>test</scope> </dependency> 我的包装注释看起来像 @Service @Transactional @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Inherited public […]

用TestNG进行Springdependency injection

Spring支持JUnit:使用RunWith和ContextConfiguration注解,事情看起来非常直观 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:dao-context.xml") 这个testing将能够在Eclipse和Maven中正确运行。 我不知道TestNG是否有类似的东西。 我正在考虑转移到这个“下一代”框架,但我没有find与春季testing匹配。

如何禁用TestNG中的整个unit testing?

这是我在JUnit中可以做的事情: import org.junit.*; @Ignore public class FooTest { // } 整个class级都会被忽略。 我如何在TestNG中做同样的事情?

TestNG中执行testing的顺序

如何自定义TestNG中testing的执行顺序? 例如: public class Test1 { @Test public void test1() { System.out.println("test1"); } @Test public void test2() { System.out.println("test2"); } @Test public void test3() { System.out.println("test3"); } } 在上面的套件中,testing的执行顺序是任意的。 对于一次执行,输出可能是: test1 test3 test2 我如何按照他们写的顺序执行testing?

@BeforeClass和inheritance – 执行顺序

我有一个抽象的基类,作为我的unit testing(TestNG 5.10)的基础。 在这个类中,我为我的testing初始化​​了整个环境,设置了数据库映射等等。这个抽象类有一个带有@BeforeClass注解的方法来完成初始化。 接下来,我用特定的类来扩展这个类,在这个类中我有@Test方法和@BeforeClass方法。 这些方法对环境进行类特定的初始化(例如,将一些logging放入数据库中)。 我怎样才能强制@BeforeClass注释方法的特定顺序? 我需要抽象基类中的那些在扩展类之前执行。 例: abstract class A { @BeforeClass doInitialization() {…} } class B extends A { @BeforeClass doSpecificInitialization() {…} @Test doTests() {…} } 预期的顺序: A.doInitialization B.doSpecificInitialization B.doTests 实际顺序: B.doSpecificInitialization // <- crashes, as the base init is missing (A.doInitialization // <—not executed B.doTests) // <-/

JUnit 4与TestNG – 2013年至2014年更新

JUnit 4和TestNG曾经是可比的。 这两个testing框架的优缺点是什么?

JUnit与TestNG

在工作中,我们目前仍在使用JUnit 3来运行我们的testing。 我们一直在考虑切换到JUnit 4来编写新的testing,但是现在我一直在关注TestNG。 你们对JUnit 4或者TestNG有什么经验,而且对于大量的testing来说,它们似乎工作得更好? 编写testing的灵活性对于我们来说也很重要,因为我们的functiontesting涵盖了一个广泛的方面,需要用各种方式编写来获得结果。 旧的testing不会被重写,因为他们的工作很好。 我希望在新的testing中看到,testing的写法,自然断言,分组和易于分布的testing执行的灵活性。

如何执行黄瓜function文件并行

我在src / test / resources / feature /中有下面的特性文件(独立的特性文件),我想并行运行它们。 就像:一个function文件必须在Chrome中执行,另一个function文件必须在firefox中执行@Tags名称。 Feature: Refund item @chrome Scenario: Jeff returns a faulty microwave Given Jeff has bought a microwave for $100 And he has a receipt When he returns the microwave Then Jeff should be refunded $100 Feature: Refund Money @firefox Scenario: Jeff returns the money Given Jeff has […]