Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
Prakash-Saravanan opened this issue Dec 30, 2016 · 4 comments

Comments

@Prakash-Saravanan
Copy link

Prakash-Saravanan commented Dec 30, 2016

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?

  • 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" } };
	}

}
@Prakash-Saravanan
Copy link
Author

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

@krmahadevan
Copy link
Member

@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.

@juherr
Copy link
Member

juherr commented Dec 30, 2016

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?

@Prakash-Saravanan Prakash-Saravanan changed the title Issue in TestNG eclipse plugin on selecting overloaded test methods Feature request: in TestNG eclipse plugin on selecting overloaded test methods Dec 30, 2016
@juherr juherr changed the title Feature request: in TestNG eclipse plugin on selecting overloaded test methods Feature request: selecting overloaded test methods (suite file and/or eclipse plugin) Dec 30, 2016
@krmahadevan
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants