Questions tagged [testng]

TestNG is a testing framework focused on providing both unit and functional testing abilities in the Java programming language. It supports parallel testing, data providers, dependencies, groups and other features.

TestNG is a testing framework inspired from JUnit and NUnit, but introducing some new functionalities that make it more powerful and easier to use, such as:

  • Annotation support.
  • Run your tests in arbitrarily big thread pools with various policies available (all methods in their own thread, one thread per test class, etc).
  • Test that your code is multi-thread safe.
  • Flexible test configuration.
  • Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Powerful execution model (no more TestSuite).
  • Supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc).
  • Embeds BeanShell for further flexibility.
  • Default JDK functions for run-time and logging (no dependencies).
  • Dependent methods for application server testing.
  • Detailed reports of executed tests.
  • Distributed testing: allows distribution of tests on slave machines.

TestNG is designed to cover all categories of tests: unit, functional, end-to-end, integration, etc.

References:

8489 questions
2
votes
1 answer

TestNG and Spring AOP

I want to add some common code (eg. log the name of the test to logback) to my testng tests via AOP. The following is my Aspect & test code: @Aspect @Component public class TestAspect { ... @Around(value = "execution(* *(..)) &&…
kulatamicuda
  • 1,603
  • 2
  • 21
  • 40
2
votes
1 answer

Selenium TestNG - DataProvider with 1D Array

I wrote a small code to search multiple keywords in google search. But it displays errors. My coding is as follows: public class GoogleSearchDataSet { WebDriver driver; @BeforeClass public void setup () { …
Saranga
  • 25
  • 6
2
votes
1 answer

Every time I write to excel, it overwrites the entire file with a blank file - PUZZLED

What I am trying to do is onTestFailure (TestNG) I am trying to write a pass/fail to a specified column. In the below code, I just wanted to do a little test to write Fail to a specified cell. But what's happening is, instead of writing a pass/fail…
user2474976
  • 87
  • 3
  • 13
2
votes
2 answers

selenium: override setUp method in super class and call super super method

I have a setUp() in my SuperTest class. Now in my ChildTest class, I want to set up another setUp(). This one will run specifically for ChildTest only. So I currently have this //SuperClass protected void setUp(ITestContext context) { …
user4036349
2
votes
1 answer

How to configure testng.xml config file to run multiple tests with before and after annotations

I am trying to run multiple tests I've written in Java using testNG unit testing and selenium UI testing frameworks. I have a configuration file setup so to make it convenient to run multiple tests. When I add in @BeforeTest and @AfterTest…
mosawi
  • 1,283
  • 5
  • 25
  • 48
2
votes
3 answers

Should Selenium tests be autonomous?

I am in the process of creating an automation framework for a new enterprise application. I am using Selenium(Webdriver), Java, Maven, and TestNG. I have read that I need to keep my tests small and autonomous, so I can run them independent of one…
Conner
  • 413
  • 2
  • 8
  • 20
2
votes
1 answer

Automate real time data using java

I am a new bee to Automation and Java. I am working on a problem which requires me to read the read time stock market data from the database and verify it with the same with the value seen on the UI. I am ok having approximations up to 5% in the…
2
votes
0 answers

TestNG is not running in parallel in eclipse

My colleague and I are working on this project using TestNG. We are using data provider and @ factory. The code runs in parallel in his system and it does not in my system! Same code! Only difference is he uses netBeans and I am using eclipse. I…
shrth
  • 223
  • 2
  • 12
2
votes
1 answer

How to avoid conflict between Mockito and PowerMockito?

I need to test a few very simple classes. The first one is Child class: public class Child extends Parent { public int newMethod() { anotherMethod(); protectedMethod(); return protectedMethodWithIntAsResult(); } …
barbara
  • 3,111
  • 6
  • 30
  • 58
2
votes
2 answers

How do I mock a method with void return type in JMockit?

I'm using TestNG and JMockit for testing. My code goes like this: public boolean testMethod(String a, String b) { //processing ..... mockClass.mockMethod(a); //processing.... } The mockMethod(): Class MockClass { public void…
user2281204
  • 81
  • 1
  • 3
  • 13
2
votes
1 answer

How to order TestNG Factory execution given a single method test and sortable test data?

First of all you should know that I am using TestNG v6.8.8 and Java JDK 6. I experience this problem running on different flavors of Linux and Mac OS 10.9.4. On to the code listing. Factory class import org.testng.annotations.Factory; import…
2
votes
0 answers

Occasional OutOfMemoryError: Java heap space when running Arquillian tests from Gradle

When running Arquillian tests from Gradle on Mac OS X (Mavericks) I regularly (but not always) get the following error (but sadly only if I have the Gradle --debug flag set). The build then hangs: 10:57:34.181 [QUIET] [system.out] 10:57:34.181…
2
votes
1 answer

Debugger does not stop on breakpoint when using testNG and Surefire

I have added testNG to my pom file and created couple of tests. @WebAppConfiguration @ContextConfiguration(classes = {PersistenceConfig.class}) @Transactional @TransactionConfiguration(defaultRollback = true) public class…
special0ne
  • 6,063
  • 17
  • 67
  • 107
2
votes
2 answers

How to use a single Spring ApplicationContext across the whole TestNG suite?

We have a separate Java project completely dedicated to functional testing of our web application with TestNG and Selenium (we refer to it as the Test Suite). It is pretty sophisticated and uses Spring for dependency injection extensively. The entry…
Actine
  • 2,867
  • 2
  • 25
  • 38
2
votes
0 answers

DBUnit cannot import data into H2 DB by xml file

I'm doing DBUnit 2.5.0 and h2 db, a memory database 1.4.180 for TestNG. I use DBUnit to export dataschema from db (PostgreSQL). Then I use this xml file for H2 DB, but whenever I run testNG, it thrown an exception:…
Phong Nguyen
  • 277
  • 4
  • 16
1 2 3
99
100