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
2 answers

How to determine where Java thread interrupts are coming from?

I've got a UI automation framework that launches tests using TestNG and runs through pages using Selenium/WebDriver. Oftentimes the pages I'm testing make AJAX calls that modify the DOM upon returning. In these cases I use Selenium explicit waits…
Alex Jansen
  • 1,455
  • 5
  • 18
  • 34
2
votes
0 answers

Guice field injection and TestNG

When developing TestNG tests with Guice, a la this: @Guice(modules=MyTestModule.class) public class MyTestClass { } It's very easy to use field injection to declare the dependencies of the test class. Now, suppose we have…
Kelvin Chung
  • 1,327
  • 1
  • 11
  • 23
2
votes
2 answers

TestNg using dependsOnMethods and priority violates priority

I've seen similar questions here but none seems to resolve the problem. I've the following code; @Test(priority=2) public void increaseQty(){ System.out.println("in increase qty");} …
Alpana Chauhan
  • 407
  • 1
  • 9
  • 18
2
votes
1 answer

How to have dynamic description for data provider tests?

I want to use @DataProvider annotation for my tests like following example: @DataProvider(name="testdata") public Object[][] testData(){ return new Object[][]{ {"http://www.google.com", "Google"}, {"http://twitter.com",…
Alpha
  • 13,320
  • 27
  • 96
  • 163
2
votes
1 answer

How can I contain test members, under a TestNG test, in their own thread?

I am attempting to run my selenium tests in parallel using TestNG as the runner. The parallel requirement is set in the testng.xml file like so. The problem I have is I want to "quit"…
Conner
  • 413
  • 2
  • 8
  • 20
2
votes
1 answer

How to write the code for listeners in TestNG?

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?
sujata
  • 21
  • 1
  • 3
2
votes
4 answers

How to check if a checkbox is enabled or not?

How to ckeck the checkbox is enabled or not? In selenium + Testng, in application im clicking on checkbox will be enabled, i need to verify whether the checkbox is enabled or not.thanks in advance.
Vids
  • 399
  • 2
  • 5
  • 11
2
votes
3 answers

Is there a possible way to run two .xml files in testng.xml parallel?

I currently have two different TestSuites (SUITE1.XML and SUITE2.xml) with different configurations (e.g browsers, Os)... I call both SUITES inside testng.xml to run on saucelabs... and it runs fine... Only what I am concerned is, I want these…
Muzamil Abbasi
  • 49
  • 1
  • 2
  • 6
2
votes
0 answers

NPE from org.glassfish.jersey.test.JerseyTest when @Test(groups = {"integration"}) through TestNG

I have a gradle project that brings in Jersey 2.13, does testing through TestNG, and leverages the Jersey Test Framework. Any test I run as a plain-jane Unit Test through the @Test annotation runs fine. If I try to put the Jersey Tests into a…
Bob Kuhar
  • 10,838
  • 11
  • 62
  • 115
2
votes
1 answer

TestNG: Changing thread counts at runtime

Suppose that I have a suite which can be executed either in parallel or serially. However, the decision to do so is left until runtime. The common way of starting this suite would be something like: TestNG runner = new TestNG(); if…
Kelvin Chung
  • 1,327
  • 1
  • 11
  • 23
2
votes
1 answer

@Optional annotation is not passing specified values with @BeforeMethod annotation in TestNG

i am currently Working on TestNG framework and facing the problem that - I have declared a method to run before every test in class by declaring a method like @BeforeMethod @Parameters({"type"}) public void beforeMethod(@Optional("Krishna") String…
krishna
  • 61
  • 1
  • 6
2
votes
1 answer

Cobertura code coverage report in Jenkins seem to give the same statistics no matter of the extension of the tests

Problem My code coverage report created from my scripts and Cobertura seem to give me the same coverage no matter of how many tests that are run. Jenkins' Cobertura plug-in always show me the same graph, should I run all or none of the…
RKrogh
  • 397
  • 2
  • 10
2
votes
1 answer

TestNG - Add custom attribute to @Test annotation

I need to add a custom attribute to existing @Test annotation like below. @Test (description = "some description", newAttribute = "some value") public void testMethod() { // unit/integration test code } Where 'newAttribute' is the new…
User_77609
  • 33
  • 1
  • 6
2
votes
3 answers

Eclipse UI freezes on running TestNG tests at 57%

I am noticing that the Eclipse UI gets stuck at 57% when I try to run the TestNG test cases. I juts have the TestNG setup in the Library (Build path) and no Jars being present. How do I fix this? I am sitting on this for hours…
user3003848
  • 69
  • 1
  • 5
2
votes
2 answers

Jenkins Publish TestNG Results not working

I am running Jenkins 1.571. I am building my project with a pom.xml. I have two executions of maven-surefire-plugin to execute two testng suites in a forked mode. But Jenkins build#/testReport page shows test results for only first suite. Build…
CoolDude
  • 417
  • 1
  • 5
  • 11
1 2 3
99
100