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

How to run java class having a relative path in it through ant

I am running a java project through build.xml using ant. There is one class which has this line: FileInputStream fis =new FileInputStream("./InputFile/"+workbookName); When I run through ant it throws java.io.FileNotFoundException:…
Sawa
  • 41
  • 3
2
votes
2 answers

Get NUnit assertion failure message

I'm pretty new in testing. After some simple exercises with Visual Studio I have turned to Nunit test framework. What I'm looking for is a property or a method to use inside a [TearDown] test method that provides me a string that contains, in…
baru
  • 401
  • 3
  • 9
  • 29
2
votes
3 answers

TestNG Factory running tests in parallel even when parallel=false is set

I am using testNG and Appium to run mobile automation.Following are my codes: package my.app.package; public class TestDataProvider { @DataProvider(parallel=false) public static Object[][] GenericDataProviderWithNoCustomCapabilities() { …
jamesdeath123
  • 4,268
  • 11
  • 52
  • 93
2
votes
2 answers

How to test that a route does not work?

How can I negate the following test? test "should route to post" do post = posts(:one) assert_routing "/posts/#{post.id}", { controller: "posts", action: "show", …
wintermeyer
  • 8,178
  • 8
  • 39
  • 85
2
votes
2 answers

PowerMockito with TestNG and Mockito framework

I am using Mockito+TestNG framework in my Project. It is used to work fine but to mock some static methods I injected PowerMock Libraries in my classpath and updated the code to use PowerMock. I am finding that whenever I try to execute: …
Nitesh
  • 27
  • 3
2
votes
3 answers

Retry failed test case in testng

I am working on a testng project and my goal is that let testng auto retry the failed test cases. For example, there are 10 test cases in the first round and 5 failed. So after first round, I let testng select the 5 failed test cases and rerun them…
Ciel
  • 5,551
  • 5
  • 17
  • 24
2
votes
1 answer

How do I ignore JAVA_TOOL_OPTIONS when running my TESTNG suite?

When I try to run my testng.xml file, it throws the following error: org.testng.TestNGException: java.lang.NullPointerException at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:341) at …
Jason Krept
  • 165
  • 1
  • 2
  • 15
2
votes
1 answer

Gradle complains about JUnit version on TestNG task

As stated in Gradle compiles but does not run TestNG tests I am having some trouble getting gradle to play nicely with TestNG. It just seems like no tests are being executed no matter what I try. So I went and tried to force gradle into executing…
titusn
  • 1,201
  • 1
  • 12
  • 43
2
votes
0 answers

rerun testng tests on configuration methods failure

I've found various methods to Rerun your failed TESTNG tests like by using IRetryAnalyzer,ITestResult , but if my configuration methods fail due to any reason like my @BEFORECLASS or @BEFORETEST or @BEFOREMETHOD how to rerun your test in such cases.
Alpana Chauhan
  • 407
  • 1
  • 9
  • 18
2
votes
2 answers

How to read an excel and fetch multiple values and concatenate them using data-provider in selenium web driver and testNG

I want to read an excel and fetch 10 records at a time and concatenate them too using data-provider in selenium web driver and testNG. For example, Excel sheet having two columns i.e, col 1, col 2 and 10 rows. Now I want to pass the fetched result…
2
votes
1 answer

How to run tests based on test tag of testng.xml using Maven?

As I know, we can run tests via maven like: For classes: mvn clean -Dtest=Class1,Class2 test For groups: mvn clean -Dgroup=groupName test But, I want to run tests based on tag mentioned in testng.xml via mvn command. I mean what command I…
Alpha
  • 13,320
  • 27
  • 96
  • 163
2
votes
1 answer

Retry only specific Failed tests with TestNG

How to execute only the specific failed tests. By using 'IRetryAnalyzer' we can re-run the failed tests for x number of time. As mentioned here Restart failed test case automatically. I have also implemented iTestListener to make the tests count…
Dev Raj
  • 650
  • 2
  • 7
  • 18
2
votes
2 answers

Spring Mockito TestNG - Mocks persist across tests

Given the following members of my test class @Mock private Gateway gateway; @Autowired @InjectMocks private TransactionManager transactionManager; @BeforeClass public void before() { MockitoAnnotations.initMocks(this); } The TransactionManager…
John Oxley
  • 14,698
  • 18
  • 53
  • 78
2
votes
0 answers

Getting string value from two dimesional object array

In TestNG I am returning two Dimensional object[][],where StaticVariable.channel_id.get(i) returns dynamic string value. But when I am trying to perform any operation on that string,which coming as parameter from this dataprovider,It's came with…
Akash Shinde
  • 925
  • 3
  • 14
  • 31
2
votes
1 answer

Define shared or fresh fixture on test method level with TestNG (or any other framework)

What I want to do is define dependencies on test methods (TestNG) define for each test method if the test fixture is shared (not reset) or re-created before the test method runs See the following example: test1 would be run first if test1…
leozilla
  • 1,296
  • 2
  • 19
  • 29