Running single dependent class via testng.xml

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Running single dependent class via testng.xml

J. N.
I have a very specific requirement:

**I need to run tests by not repeating/ re-writing the dependent classes in < classes > in the testing.xml** 

I have researched my issue extensively and only when I didn’t find solution, I am writing this question. I hope I have provided all info needed to help me find solution. 

The sample project has been added here: https://github.com/jigyasa-at-git/testngDependencyManagement/tree/master/dependencyManagement 

**Setup:**

- I am using TestNG (6.13.1).
- I have huge number of classes in the suite. 
- Each class contains 1 method (this is how the project needs to be set up )
- Some classes have dependencies on other classes (meaning, the methods    inside of the class have dependencies on methods in another class and    I am using “dependsOnGroups” annotation).
- I am using testing.xml for running my tests.  I am defining the dependencies inside the classes.
- This is the dependency structure in sample project:
    * Method in ClassTwo depends on method in ClassOne. 
    * Method in ClassThree depends on method in ClassTwo
    * Method in ClassFour depends on method in ClassThree

**Original Testing.xml:** (this is what I want to work)

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="Test Dependencies">
    <test name="Test 1">
    <classes>
    <class name="ClassOne" />
    <class name="ClassTwo" />
    </classes>
    </test>
    <test name="Test 2">
    <classes>
    <class name="ClassThree" />
    </classes>
    </test>
    <test name="Test 3">
    <classes>
    <class name="ClassFour" />
    </classes>
    </test>
    </suite>

**Issue:**
I am getting the following error when I run the above testing.xml:

org.testng.TestNGException: 
DependencyMap::Method "ClassThree.classThree_Test1()[pri:0, instance:ClassThree@475530b9]" depends on nonexistent group "classTwo"

On the other hand, it works if the testing.xml is updated like so:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="Test Dependencies">
    <test name="Test 1">
    <classes>
    <class name="ClassOne" />
    <class name="ClassTwo" />
    </classes>
    </test>
    <test name="Test 2">
    <classes>
    <class name="ClassOne" />
    <class name="ClassTwo" />
    <class name="ClassThree" />
    </classes>
    </test>
    <test name="Test 3">
    <classes>
    <class name="ClassOne" />
    <class name="ClassTwo" />
    <class name="ClassThree" />
    <class name="ClassFour" />
    </classes>
    </test>
    </suite>

Tests run fine, but then I face another problem … those classes (ClassOne, ClassTwo and ClassThree) run multiple times since they are mentioned in all 3 < test >

I have googled this issue a lot but am not able to find any solution. Would really appreciate any help. I am stuck badly. I need a way to resolve dependencies without making the classes to run multiple times or having to manually add them to the < classes >

I have posted on stackoverflow as well:
https://stackoverflow.com/questions/48173700/running-single-dependent-class-via-testng-xml

I really need help!!

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.