Testng: Feature request: selecting overloaded test methods (suite file and/or eclipse plugin)

Created on 30 Dec 2016  路  4Comments  路  Source: cbeust/testng

TestNG Version

Note: only the latest version is supported
6.10

Expected behavior

Having more than one methods in a class with same name and different signature (method overloading) and selecting (by double clicking the method name) and running one test method, it should run the selected method alone.

Actual behavior

It executes all the methods with that name.

Is the issue reproductible on runner?

  • [x] Eclipse

Test case sample

import org.testng.ITestContext;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

public class TestNGIssue {

    @Test
    public void test() {
        System.out.println("test without param");
    }

    @Test
    public void test(ITestContext context) {
        System.out.println("test with param as itestcontext");
    }

    @Test(dataProvider = "data")
    public void test(String name) {
        System.out.println("test with param as string");
    }

    @DataProvider(name = "data")
    public Object[][] dataprovider() {
        return new Object[][] { { "name" } };
    }

}
test selection Feature request

Most helpful comment

@Prakash-Saravanan - I think that's the expected behaviour. TestNG resorts to reflection to find methods, but it doesn't differentiate methods based on their signatures, but resorts to finding methods based on ONLY names. So IMO this is not an issue but TestNG is working as designed.

All 4 comments

When running as an XML file, it will run all the methods.
Is this an expected behavior with Eclipse runner too?

@Prakash-Saravanan - I think that's the expected behaviour. TestNG resorts to reflection to find methods, but it doesn't differentiate methods based on their signatures, but resorts to finding methods based on ONLY names. So IMO this is not an issue but TestNG is working as designed.

Could be an improvement on test selection or, at least, testng may warn if it found many methods with the same name.

@krmahadevan @cbeust What do you think?

@juherr - I think that makes sense to add a warning (at-least) informing the user of multiple overloaded versions of the same test method.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mobrockers picture Mobrockers  路  25Comments

docian picture docian  路  37Comments

freakerhere picture freakerhere  路  35Comments

Janani picture Janani  路  22Comments

frekele picture frekele  路  20Comments