testng

TestNG call sequence of @AfterMethod and ITestListener#onFailure

Does anybody know what is called first if a test fails? ...

@BeforeClass and inheritance - order of execution

I have an abstract basis class, which I use as a basis for my unit tests (TestNG 5.10). In this class I initialize the whole environment for my tests, setting up database mappings, etc. That abstract class has a method with a @BeforeClass annotation which does the initialization. Next thing, I extend that class with specific classes in w...

TestNG multithreaded test with Spring @Transactional

I am using TestNG to test persistence Spring modules (JPA+Hibernate) using AbstractTransactionalTestNGSpringContextTests as a base class. All important parts @Autowired, @TransactionConfiguration, @Transactional work just fine. The problem comes when I am trying to run test in parallel threads with threadPoolSize=x, invocationCount=y Te...

Passing Object Parameters for TestNG methods?

Here is my situation. Before my tests are run, in the beforesuite, I instantiate a bunch of "environment objects" These objects get created based on my environment configuration file. It is my tests that will actually be using these environment objects. The problem is how can I pass them to the tests. Your first impulse might be to ...

Is it possible to use the TestNG plugin with Netbeans 6.8?

I downloaded the TestNG NetBeans Plugin and tried to install it in my NetBeans 6.8. I'm running NetBeans IDE 6.8 (Build 200912041610). When I click install, I get this message: Some plugins require plugin External Execution Support to be installed. The plugin External Execution Support is requested in version >= 1.19 but onl...

TestNG Dataprovider size

Is it possible to get the number of elements in a TestNG DataProvider array at runtime? ...

Getting black images with selenium.captureScreenshot

I'm executing selenium tests with testng, that are started on a remote system with Selenium RC via hudson (with ssh connection). The remote system is windows xp with MKS Toolkit installed, hence ssh. Tests are NOT executed as a windows service. I've tried using both captureScreenshot and captureEntirePageScreenshot methods. The first...

What are the default listeners in TestNG, and where do I find this list?

I was curious to know what the default listeners are in TestNG. I saw a bool property on the Ant task for useDefaultListeners but I would like to know what these are and where I can find them. ...

Unit test framework - TestNG using configurable value to define threadPoolSize

Hi guys.... I'm digging little bit the TestNG framework. I'm using annotations to configure thread values in my test case, example: @Test(threadPoolSize = 2, invocationCount = 10) public void testOne() { //some code } The idea is config these values in a config file and this values should be passed to all tests. So I...

Servlet unit test

Currently I'm using TestNG framework for testing application business logic, i added some Servlet classes recently. How do I unit test these Servlet classes in TestNg framework? ...

Spring Dependency Injection with TestNG

Spring support JUnit quite well on that: With the RunWith and ContextConfiguration annotation, things look very intuitive @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:dao-context.xml") This test will be able to run both in Eclipse & Maven in correctly. I wonder if there is similar stuff for Test...

Unbelievable: Cannot cast from class X to its super class

I'm encountering a very weird problem with Spring (3.0.1.RELEASE), TestNG (5.11) and Maven Surefire (2.5). I have a test class that extends a Spring helper class for testNG so that test context can be loaded from an xml file (that contains some bean definitions). My project was imported into eclipse using m2eclipse (using Import Maven Pr...

Group testNG tests without annotations

Hi gents and ladies, I'm responsible for allowing unit tests for one of ETL components.I want to acomplish this using testNG with generic java test class and number of test definitions in testng.xmlpassing various parameters to the class.Oracle and ETL guys should be able to add new tests without changing the java code, so we need to us...

Does TestNG has runner like SpringJUnit4ClassRunner

Hi, When I write tests in JUnit (in Spring context) I usualy do it like this: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:testContext.xml") public class SimpleTest { @Test public void testMethod() { // execute test logic... } } How can I do the same with TestNG? ...

TestNG's groups

If we have <include name="web" > and <include name="weekend" >, TestNG runs all the methods that belong to either web or weekend. Is it possible to change this behaviour so TestNG would run all the methods that belong to web and weekend? Does anyone knows a way to accomplish this? ...

Is there a Java Package for testing RESTful APIs?

I'm getting ready to dive into testing of a RESTful service. The majority of our systems are built in Java and Eclipse, so I'm hoping to stay there. I've already found rest-client (http://code.google.com/p/rest-client/) for doing manual and exploratory testing, but is there a stack of java classes that may make my life easier? I'm using...

How do I test expectedExceptionsMessageRegExp (exception message) using TestNG?

I'm using expectedExceptionsMessageRegExp annotation to test exception message, but the this is not executing correctly.please see the below code. Unit Test code: @Test (dependsOnMethods = "test1", expectedExceptions = IllegalArgumentException.class , expectedExceptionsMessageRegExp = "incorrect argument") public void ...

NoSuchMethodError with Spring MutableValues

Hello experts! I have written a test where i specify my application context location with annotations. I then autowire my dao into the test. @ContextConfiguration(locations = {"file:service/src/main/webapp/WEB-INF/applicationContext.xml"}) public class MyTest extends AbstractTestNGSpringContextTests { @Autowired ...

order of execution of tests in testng

How to customize the order of execution of tests in testng ? For example: @Test 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"); } } In the above suit...

How to write the code for listeners in TestNG?

Hi, I want to know how can i use listeners in my java code? Also what changes are to made in the xml file if i want to incorporate the listeners? I added org.testng.ITestNGListener then too the program is throwing errors? ...