Skip to content

Commit

Permalink
Enabled tests for annotation transformers on both JDK 1.4 and 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeust committed Oct 15, 2006
1 parent 124444c commit 9fea191
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.testng.Assert;
import org.testng.TestNG;

import test.annotationtransformer.MyTransformer;

public class AnnotationTransformerSampleTest {

private int m_two = 0;
Expand All @@ -15,36 +17,41 @@ public class AnnotationTransformerSampleTest {
*/
public void two() {
m_two++;
System.out.println("Should be invoked 2 times");
ppp("Should be invoked 2 times");
}

/**
* @testng.test invocationCount = 5
*/
public void four() {
m_four++;
System.out.println("Should be invoked 4 times");
ppp("Should be invoked 4 times");
}

/**
* @testng.test invocationCount = 5
*/
public void three() {
m_three++;
System.out.println("Should be invoked 3 times");
ppp("Should be invoked 3 times");
}

/**
* @testng.test
*/
public void five() {
m_five++;
System.out.println("Should be invoked 5 times");
ppp("Should be invoked 5 times");
}

/**
private void ppp(String string) {
if (false) {
System.out.println("[AnnotationTransformerSampleTest] " + string);
}
}

/**
* @testng.test dependsOnMethods = "two three four five"
*
*/
public void verify() {
Assert.assertEquals(m_two, 2);
Expand All @@ -56,11 +63,13 @@ public void verify() {

public static void main(String[] argv) {
TestNG tng = new TestNG();
tng.setVerbose(0);
tng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
tng.setSourcePath("test-14/src");
tng.setAnnotationTransformer(new MyTransformer());
tng.setTestClasses(new Class[] { AnnotationTransformerSampleTest.class});

tng.run();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.List;

import org.testng.Assert;
import org.testng.ITestResult;
import junit.framework.Assert;

import org.testng.TestListenerAdapter;
import org.testng.TestNG;

Expand All @@ -16,6 +16,7 @@ public class AnnotationTransformerTest extends BaseTest {
*/
public void verifyInvocationCount() {
TestNG tng = new TestNG();
tng.setVerbose(0);
tng.setDefaultAnnotations(TestNG.JAVADOC_ANNOTATION_TYPE);
tng.setSourcePath("test-14/src");
tng.setAnnotationTransformer(new MyTransformer());
Expand Down
2 changes: 1 addition & 1 deletion test-14/testng-single.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ thread-count="2" annotations="javadoc">

<test name="Regression2">
<classes>
<class name="test.dataprovider.StaticDataProviderSampleTest" />
<class name="test.annotationtransformer.AnnotationTransformerTest" />
</classes>
</test>

Expand Down
1 change: 1 addition & 0 deletions test-14/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<class name="test.thread.SequentialTest" />
<class name="test.configuration.GroupLessTest" />
<class name="test.reports.ReportTest" />
<class name="test.annotationtransformer.AnnotationTransformerTest" />
</classes>
</test>
<!--
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ public class AnnotationTransformerSampleTest {
@Test(invocationCount = 2)
public void two() {
m_two++;
System.out.println("Should be invoked 2 times");
ppp("Should be invoked 2 times");
}

@Test(invocationCount = 5)
public void four() {
m_four++;
System.out.println("Should be invoked 4 times");
ppp("Should be invoked 4 times");
}

@Test(invocationCount = 5)
public void three() {
m_three++;
System.out.println("Should be invoked 3 times");
ppp("Should be invoked 3 times");
}

@Test
public void five() {
m_five++;
System.out.println("Should be invoked 5 times");
ppp("Should be invoked 5 times");
}

@Test(dependsOnMethods = {"two", "three", "four", "five"})
Expand All @@ -51,4 +51,10 @@ public static void main(String[] argv) {

tng.run();
}

private void ppp(String string) {
if (false) {
System.out.println("[AnnotationTransformerSampleTest] " + string);
}
}
}
26 changes: 26 additions & 0 deletions test/src/test/annotationtransformer/AnnotationTransformerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package test.annotationtransformer;

import java.util.List;

import org.testng.Assert;
import org.testng.TestListenerAdapter;
import org.testng.TestNG;
import org.testng.annotations.Test;

public class AnnotationTransformerTest {

@Test
public void verifyAnnotationTransformer() {
TestNG tng = new TestNG();
tng.setVerbose(0);
tng.setAnnotationTransformer(new MyTransformer());
tng.setTestClasses(new Class[] { AnnotationTransformerSampleTest.class});
TestListenerAdapter tla = new TestListenerAdapter();
tng.addListener(tla);

tng.run();

List passed = tla.getPassedTests();
Assert.assertEquals(15, passed.size());
}
}
4 changes: 2 additions & 2 deletions test/testng-single.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
<class name="test.thread.SequentialSample3Test" />
<parameter name="source-directory" value="test/src/test/converter" />
<class name="test.thread.ParallelTestTest" />
<class name="test.annotationtransformer.AnnotationTransformerSampleTest" />
<class name="test.reports.ReportTest" />
<class name="test.CommandLineTest" ></class>
-->
<classes>
<class name="test.CommandLineTest" ></class>
<class name="test.annotationtransformer.AnnotationTransformerTest" />
</classes>
</test>

Expand Down
1 change: 1 addition & 0 deletions test/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
<class name="test.configuration.BeforeTestOrderingTest" />
<class name="test.configuration.SuiteTest" />
<class name="test.configuration.VerifySuiteTest" />
<class name="test.annotationtransformer.AnnotationTransformerTest" />
</classes>
</test>

Expand Down

0 comments on commit 9fea191

Please sign in to comment.