Thanks for the reply Cedric. Here are the exact problems I'm facing. Not sure if I'm missing something here, or got the basics wrong!
1) My JUnit test suites have static variables at the test class level. I converted the class to TestNG
- testA updates the value of the static variable during the test
- testB runs, expecting the value to be as before, but fails since the value is now different!
2) My JUnit test refers to framework classes that internally use singletons. The createSingleton method will create different objects based on test scenario. I converted the class to TestNG
- testA initialized the singleton based on testScenario1
- testB creates testScenario2. However, the singleton simply returns the previously created object, instead of creating it over again! Test fails :(
3) My JUnit creates new MBeanServer with different domain names, to mimic different containers like "geronimo","tomcat","DefaultDomain", etc. I convert the test to TestNG
- testA initialized testScenario by setting MBeanServer for container "Geronimo". The underlying MBeanServerFactory of javax stores these in a static final list.
- testB initialized testScenario by setting MBeanServer for container tomcat. The underlying MBeanServerFactory of javax adds this to the same static final list. My test fails sporadically, as it sometimes detects enviroment as "tomcat" and sometimes as "geronimo"
These are some samples. It seems strange to me that nobody else faces the same problems?? It seems natural that test classes would attempt to use different values for static and final variables across tests.
Do you know at what level does testng group tests by classloader? (e.g. All tests in one class, all tests per package, all tests for any testng run)
Thanks in advance!
Zeba