Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8725427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:02:16+00:00 2026-06-13T08:02:16+00:00

I have a testNG framework that I was asked to make runnable via the

  • 0

I have a testNG framework that I was asked to make runnable via the command line. I’ve added the code to execute the tests, but part of the command line execution was passing in the test class to be executed. Java doesn’t seem to like this.

My Code:

    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();

    try
    {
        Class cl = Class.forName(myClass);
        testng.setTestClasses(new Class[] { cl.class });
        testng.addListener(tla);
        testng.run();
    }
    catch (Exception ex)
    {
    ...
    }

The variable myClass is one of the arguments passed into Main.

I receive an error on the “cl.class” code of “unknown class”.

What would be the proper way of doing this?

EDIT:

When actually building the project, the error returned is “error: cannot find symbol class cl”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:02:17+00:00Added an answer on June 13, 2026 at 8:02 am

    the issue may be that you are putting cl.class in your Class array. cl is a class object. Try

    testng.setTestClasses(new Class[] { cl });
    

    You can read more about the Class class here http://docs.oracle.com/javase/tutorial/reflect/class/classNew.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At present I have a TestNG project that calls a JBoss RESTEasy web service.
I have java 1.6, maven 2, activeMQ 5.5 and functional tests with testng. When
I have created a iOS framework and want to use that framework in one
I have a build script (.bat) that invokes MSBUILD ( C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe ) that used
I have been working on a web development library (for the CodeIgniter framework) that
I have a piece of code similar to the below that I have been
I have a Rails 3 app that uses RSpec2 as my testing framework, and
In most framework unit testing implementations, you have a set of a tests and
I have read so many places is that if your code is not test-able
Can anybody advice some good unit testing framework/tool for complicated project that have AJAX

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.