You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2009/09/21 22:18:10 UTC

svn commit: r817397 - in /jakarta/jmeter/trunk/src/junit/test: ./ DummyAnnotatedTest.java

Author: sebb
Date: Mon Sep 21 20:18:09 2009
New Revision: 817397

URL: http://svn.apache.org/viewvc?rev=817397&view=rev
Log:
Bugzilla 47803 - Support for JUnit 4.x tests defined by annotations
Sample test cases

Added:
    jakarta/jmeter/trunk/src/junit/test/
    jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java   (with props)

Added: jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java?rev=817397&view=auto
==============================================================================
--- jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java (added)
+++ jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java Mon Sep 21 20:18:09 2009
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+*/
+
+package test;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DummyAnnotatedTest
+{
+    public String name;
+    public int two = 1; //very wrong.
+    
+    public DummyAnnotatedTest() {
+        name="NOT SET";
+    }
+    public DummyAnnotatedTest(String name) {
+        this.name = name;
+    }
+
+    @Test(expected=RuntimeException.class)
+    public void fail() {
+        throw new RuntimeException();
+    }
+    
+    @Before
+    public void verifyTwo() {
+        two = 2;
+    }
+    
+    @After
+    public void printDone() {
+        System.out.println("done with an annotated test.");
+    }
+    
+    @Test
+    public void add() {
+        int four = two+2;
+        if(4!=four) {
+            throw new RuntimeException("4 did not equal four.");
+        }
+        //or if you have assertions enabled
+        assert 4 == four;
+    }
+    
+    //should always fail
+    @Test(timeout=1000)
+    public void timeOut() {
+        try{
+            Thread.sleep(2000);
+        }catch (InterruptedException e) { }
+    }
+}

Propchange: jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/jmeter/trunk/src/junit/test/DummyAnnotatedTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org