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 8370957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:02:27+00:00 2026-06-09T14:02:27+00:00

I have a TestNG test that works as expected when run as TestNG Suite

  • 0

I have a TestNG test that works as expected when run as TestNG Suite in Eclipse, but fails when run via TestNG Ant Task (also via Eclipse). The same test also fails when I run Ant via the command line. The build succeeds, but the test fails with the message:

org.testng.TestNGException:
Parameter 'homepage.title' is required by @Test on method login but has not been marked @Optional or defined

The parameter is defined correctly in my TestNG.xml, and as I mentioned, the same test passes if I run via “Run as TestNG Suite”

Thanks in advance! I hope to be able to help others out as well!

  • 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-09T14:02:28+00:00Added an answer on June 9, 2026 at 2:02 pm

    It looks like you define a parameter for the test but not specify a value for it.

    @Test
    public void myTest(String myParameter){
    }
    

    There are several ways to solve this.
    One would be to specify Parameter annotation and pass parameter in either testng.xml or in through jvm arg:

    @Test
    @Parameters({"myParameter"})
    public void myTest(String myParameter){
    }
    

    testng.xml file:

    <suite>
        <test>
             <parameter name="myParameter" value="myValue" />
             <classes>
                  <class name="org.example.MyTestClass" />
             </classes>
        </test>
    </suite>
    

    or in build.xml file specify jvmarg property:

    <testng>
       <jvmarg value="-DmyParameter=myValue" />
       <!-- ... -->
    </testng>
    

    The other way, that is suggested by the TestNG, is to annotate parameter with @Optional:

    @Test
    @Parameters({"myParameter"})
    public void myTest(@Optional("myValue") String myParameter){
    }
    

    On the additional note, the reason why your build might be passing is whether you tell Ant to fail the build on the test failure. In this case if the build compiles, but there is a test failed, the build will still report “Succeeded” result:

    <testng haltonfailure="true">
       <!-- ... -->
    </testng>
    

    The default value for haltonfailure property is “false”.

    Please refer to TestNG documentation for more information on parameters and how to use TestNG with Ant.

    • 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 am trying to use Qunit to test some code, but I have some
I have a feeling that I'm missing something obvious but can't seem to resolve
I have several integration tests for various services that extend the following baseclass: @ContextConfiguration(locations=classpath:applicationContext-test.xml)
I have the following JUnit test. The method that I'm testing is quite simple,
I am new to testing.I have to test some C# classes.Kindly let me know
I am writing some unit test and I have a unit testing base class
I am new to junit testing and I have the following test - public
I'm stress testing a web app and have set up a windows test program
I have a project structure like: src/CMakeLists.txt src/test/component1/CMakeLists.txt src/test/component2/CMakeLists.txt For the testing, I'm using

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.