question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

supporting parameters at method level?

See original GitHub issue

Is it possible to support special parameters at method level? For instance,

<test name="Regression1">
<groups>
    <run>
      <exclude name="brokenTests"  />
      <include name="checkinTests"  />
    </run>
  </groups>

  <classes>
    <class name="test.IndividualMethodsTest">
      <methods>
        <include name="testMethod" param1="121" param2="1212"  />
      </methods>
    </class>
  </classes>
</test>

I am trying to achieve this by modifying testng code - I would appreciate any guidance/start for this.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
drapostoloscommented, Oct 14, 2015

Actually, parameters on method level exists. Here is an example:

<suite name="my-suite" verbose="1">
    <test name="my-test">
        <classes>
            <class name="testng.ex1.TestParams">
                <methods>
                    <include name="m1">
                        <parameter name="key1"  value="val1"/>
                        <parameter name="key2"  value="val2"/>
                    </include>
                    <include name="m2">
                        <parameter name="key1"  value="valA"/>
                        <parameter name="key2"  value="valB"/>
                    </include>
                </methods>
            </class>
        </classes>
    </test>
</suite>
package testng.ex1;

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class TestParams {

    @Test
    @Parameters({ "key1", "key2" })
    public void m1(String key1, String key2) throws Exception {
        System.out.println(key1 + ", " + key2);
    }

    @Test
    @Parameters({ "key1", "key2" })
    public void m2(String key1, String key2) throws Exception {
        System.out.println(key1 + ", " + key2);
    }
}
1reaction
juherrcommented, Oct 14, 2015

👍 Good to know! I’ve never seen it before.

@JayVem I close the issue as it already exists.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TestNG @Parameters - Passing Parameters to Tests
TestNG @Parameters annotation allows users to pass parameters to tests as arguments. Optional parameters can be sent with @Optional.
Read more >
Passing Parameters at Test Method Level in TestNG
Hello Folks, In this post we will learn an important concept of parameters in TestNG. We know that we can create parameterised methods...
Read more >
Parameterized Tests In TestNG Using Selenium - Tools QA
Parameters pass the values in the runtime. An example of using the parameters in TestNG can be entering different values in an input...
Read more >
TestNG - Parameterized Test - Tutorialspoint
TestNG lets you pass parameters directly to your test methods in two different ways − ... We can also define the parameters at...
Read more >
Parameterization in TestNG | Suite Level | @Optional annotation
In this session 9 in TestNG series, we will learn Parameterization in TestNG by using @ Parameters annotation in testng class and parameter...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found