~ubuntu-branches/ubuntu/utopic/testng/utopic

« back to all changes in this revision

Viewing changes to test/v4/src/test/CtorCalledOnce.java

  • Committer: Bazaar Package Importer
  • Author(s): Marcus Better
  • Date: 2009-05-04 10:47:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090504104743-1gbwsis9q1fh3aaj
Tags: upstream-5.9+dfsg
ImportĀ upstreamĀ versionĀ 5.9+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package test;
 
2
 
 
3
import org.testng.annotations.Configuration;
 
4
import org.testng.annotations.Test;
 
5
 
 
6
/**
 
7
 * this test verifys that the test class is instantiated exactly once
 
8
 * regardless of how many test methods we have, showing that TestNG
 
9
 * semantics is quite different from JUnit
 
10
 */
 
11
public class CtorCalledOnce {
 
12
  public static int instantiated = 0;
 
13
  public CtorCalledOnce() {
 
14
    instantiated++;
 
15
  }
 
16
 
 
17
  @Test
 
18
  public void testMethod1(){
 
19
    assert instantiated == 1 : "Expected 1, was invoked " + instantiated + " times";
 
20
  }
 
21
 
 
22
  @Test
 
23
  public void testMethod2(){
 
24
    assert instantiated == 1 : "Expected 1, was invoked " + instantiated + " times";
 
25
  }
 
26
 
 
27
  @Test
 
28
  public void testMethod3(){
 
29
    assert instantiated == 1 : "Expected 1, was invoked " + instantiated + " times";
 
30
  }
 
31
  
 
32
  @Configuration(afterTest = true)
 
33
  public void afterTest() {
 
34
    instantiated = 0;
 
35
  }
 
36
 
 
37
}
 
 
b'\\ No newline at end of file'