Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

TestNG skips tests - even with no test failures.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the following testNG xml file, I notice that not only the first test of each class is executed AND the @AfterClass method is not executed. After the first test finishes execution, the @BeoreClass of the next test-class is executed.

The execution fails because the @AfterClass method is supposed to clean-up after all tests in the class are executed.  Also, in the test code, I am using @Test(priority=<number>, alwaysRun = true)

Here's the xml file.

 
Sammy Patel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone???
 
author & internet detective
Posts: 39996
807
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sammy,
More people use JUnit than TestNG. And this is a really specific question. I wouldn't be surprised if nobody knows.
 
Sammy Patel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, this is a basic question - why @AfterClass method is not getting executed.  I am not sure about no TestNG user having run into this situation
 
Jeanne Boyarsky
author & internet detective
Posts: 39996
807
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought you were saying that @AfterClass wasn't getting executed in a specific circumstance. If that isn't the case, can you be more specific.

Can you narrow the scenario down so it only has two test classes and post them here?
 
Sammy Patel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeanne,

Sorry, if my comments are confusing.  At this point, even I am confused!

Here's the situation:
- The tests are launched
- First test of the first class is executed
- The rest of the tests are skipped
- Control goes on to run the tests of the next class - but in between, the @AfterClass of the previous test class is not executed

So, as I see, there are two issues:
  1.  Why is only the first test of each test class is executed (i.e. the rest of the tests are skipped - not even attempted to be executed)
  2.  Why is @AfterClass method of each test class is not exevuted

Hope this helps....

Regards.
 
Jeanne Boyarsky
author & internet detective
Posts: 39996
807
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sammy,
A general troubleshooting approach is to make the problem smaller. Can you reproduce it with a project that only has two simple tests and no dependencies? And post them here.
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic