Skip to content

Commit

Permalink
Merge pull request #1485 from krmahadevan/krmahadevan-fix-1484
Browse files Browse the repository at this point in the history
Remove irrelevant "targets" for TestNG annotations
  • Loading branch information
cbeust committed Jul 22, 2017
2 parents 35805f4 + 3a5f960 commit 08a8039
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 37 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Current
Fixed: GITHUB-1484: Remove irrelevant "targets" for TestNG annotations (Krishnan Mahadevan)
Fixed: GITHUB-1405: Skip considering main() method when @Test used at class level (Krishnan Mahadevan)
Fixed: GITHUB-799: @Factory with dataProvider changes order of iterations (Krishnan Mahadevan & Julien Herr)
New: Enhance XML Reporter to be able to customize the file name (Krishnan Mahadevan)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/testng/annotations/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Cedric Beust, Apr 26, 2004
*/
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
@Target({METHOD, TYPE, CONSTRUCTOR})
@Target({METHOD, TYPE})
public @interface Test {
/**
* The list of groups this class/method belongs to.
Expand Down
30 changes: 1 addition & 29 deletions src/test/java/test/mannotation/MAnnotationSampleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
import org.testng.internal.annotations.IAnnotationFinder;
import org.testng.internal.annotations.IBeforeSuite;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

@Test(enabled = true)
@Test
public class MAnnotationSampleTest {
private IConfiguration m_configuration = new org.testng.internal.Configuration();
private IAnnotationFinder m_finder;
Expand Down Expand Up @@ -81,30 +80,6 @@ public void verifyTestMethodLevel() throws SecurityException, NoSuchMethodExcept
Assert.assertEquals(exceptions[0], NullPointerException.class);
}

public void verifyTestConstructorLevel() throws SecurityException, NoSuchMethodException
{
//
// Tests on MTest1SampleTest
//
Constructor constructor = MTest1.class.getConstructor(new Class[0]);
ITestAnnotation test1 = (ITestAnnotation) m_finder.findAnnotation(constructor, ITestAnnotation.class);
Assert.assertNotNull(test1);
Assert.assertTrue(test1.getEnabled());
Assert.assertEqualsNoOrder(test1.getGroups(), new String[] { "group5", "group1", "group6", "group2" });
Assert.assertTrue(test1.getAlwaysRun());
Assert.assertEquals(test1.getParameters(), new String[] { "param5", "param6" });
Assert.assertEqualsNoOrder(test1.getDependsOnGroups(), new String[] { "dg1", "dg2", "dg5", "dg6" });
Assert.assertEqualsNoOrder(test1.getDependsOnMethods(), new String[] { "dm1", "dm2", "dm5", "dm6" });
Assert.assertEquals(test1.getTimeOut(), 242);
Assert.assertEquals(test1.getInvocationCount(), 243);
Assert.assertEquals(test1.getSuccessPercentage(), 62);
Assert.assertEquals(test1.getDataProvider(), "dp3");
Assert.assertEquals(test1.getDescription(), "Constructor description");
Class[] exceptions = test1.getExpectedExceptions();
Assert.assertEquals(exceptions.length, 1);
Assert.assertEquals(exceptions[0], NumberFormatException.class);
}

public void verifyConfigurationBefore() throws SecurityException, NoSuchMethodException
{
Method method = MTest1.class.getMethod("before", new Class[0]);
Expand Down Expand Up @@ -247,7 +222,4 @@ public void verifyNewConfigurationAfter() throws SecurityException, NoSuchMethod
Assert.assertFalse(configuration.getAlwaysRun());
}

private static void ppp(String s) {
System.out.println("[MAnnotationSampleTest] " + s);
}
}
8 changes: 1 addition & 7 deletions src/test/java/test/mannotation/MTest1.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
dataProvider = "dp", description = "Class level description")
public class MTest1 {

@Test(enabled = true, groups = {"group5", "group6"},
alwaysRun = true, parameters = {"param5", "param6"},
dependsOnGroups = {"dg5", "dg6"}, dependsOnMethods = {"dm5", "dm6"},
timeOut = 242, invocationCount = 243, successPercentage = 62,
dataProvider = "dp3", description = "Constructor description",
expectedExceptions = NumberFormatException.class)
public MTest1() {}

@Test(enabled = true, groups = {"group3", "group4"},
Expand Down Expand Up @@ -59,7 +53,7 @@ public void after() {}
description = "beforeSuite description")
@DataProvider(name = "dp4")
@ExpectedExceptions({MTest1.class, MTest2.class })
public void otherConfigurations() {}
public Object[][] otherConfigurations() { return null;}

@Factory(parameters = {"pf1", "pf2"})
public void factory() {}
Expand Down

0 comments on commit 08a8039

Please sign in to comment.