Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Help Needed: TestNG Class Not Found & Resource Not Found Errors During Dynamic Test Selection

34 views
Skip to first unread message

Prabhudatta Behera

unread,
Sep 19, 2024, 5:39:35 AM9/19/24
to testng-dev

 Hi everyone,

I’m facing an issue while trying to dynamically select and run specific test classes using TestNG based on checkboxes in a web UI. I'm attempting to run only the selected classes, but I'm encountering several errors related to missing resources and class not found exceptions.

Here’s what I’ve done:
  • I have a servlet that receives selected test classes from checkboxes in the web UI and passes those classes to TestNG for execution.
  • TestNG runs programmatically using the TestNG and XmlSuite classes.
  • However, when I run the selected tests, I get the following errors:
[ERROR org.testng.reporters.SuiteHTMLReporter - test-output\testng.css]
[ERROR org.testng.reporters.jq.Main - test-output\jquery-3.6.0.min.js]
java.nio.file.NoSuchFileException: test-output\jquery-3.6.0.min.js
[ERROR org.testng.internal.Utils - The system cannot find the path specified]
java.io.IOException: The system cannot find the path specified
[ERROR org.testng.reporters.EmailableReporter2 - Unable to create output file]
java.nio.file.NoSuchFileException: test-output\emailable-report.html

Steps Taken:
  • I’ve confirmed that the selected classes exist and are correctly passed to TestNG.
  • I’ve tried setting a custom output directory for the test reports.
  • I made sure the testng.xml is configured properly and is being referenced with the correct path.
  • Checked file permissions and ensured that the servlet has write access to the directories.
The Issue:
  • The system cannot find the required files like testng.css, jquery-3.6.0.min.js, or even emailable-report.html in the test-output folder.
  • Additionally, I get class not found exceptions when running selected test classes.
My Question:
  1. Is this a TestNG configuration issue, or am I missing something with the file generation?
  2. How can I ensure that TestNG generates the necessary files like CSS and JS for the HTML reports?
  3. Any insights into resolving the class not found issue when running dynamically selected test classes?
  Code for Running TestNG :  
TestNG testng = new TestNG();
XmlSuite suite = new XmlSuite();
suite.setName("Sabhyasha Test Suite");

// Dynamically setting classes based on selected checkboxes
List<XmlClass> classes = new ArrayList<>();
// Assume selectedClasses is a List<String> from UI input
for (String className : selectedClasses) {
    classes.add(new XmlClass(className));
}

XmlTest test = new XmlTest(suite);
test.setXmlClasses(classes);

testng.setXmlSuites(Collections.singletonList(suite));
testng.setOutputDirectory("test-output");
testng.run();

Thanks in advance for your help! Any suggestions or advice would be greatly appreciated.  




Krishnan Mahadevan

unread,
Sep 20, 2024, 2:13:29 AM9/20/24
to testn...@googlegroups.com
Is there some additional context that you can share ?

* TestNG version that you are using
* A sample project that we can use to reproduce the problem ( I mean basically a sample web app that we can use to reproduce the problem). I ask this because this wouldn’t show up in a regular scenario and I was hoping that we can get to see exactly how you are using TestNG in your use case to suggest the fixes)




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribblings @ https://rationaleemotions.com/

--
You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-dev/ef9f770a-53c9-4a44-8cf3-65ef62369ce0n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages