-
Notifications
You must be signed in to change notification settings - Fork 2
/
JUnitSuite.scala
64 lines (63 loc) · 3.08 KB
/
JUnitSuite.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright 2001-2023 Artima, Inc.
*
* Licensed 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 org.scalatestplus.junit5;
/**
* A suite of tests that can be run with either JUnit or ScalaTest. This class allows you to write JUnit 5 tests
* with ScalaTest's more concise assertion syntax as well as JUnit's assertions (<code>assertEquals</code>, etc.).
* You create tests by defining methods that are annotated with <code>Test</code>, and can create fixtures with
* methods annotated with <code>Before</code> and <code>After</code>. For example:
*
* <pre class="stHighlighted">
* <span class="stReserved">import</span> org.scalatest.junit5.JUnitSuite
* <span class="stReserved">import</span> scala.collection.mutable.ListBuffer
* <span class="stReserved">import</span> _root_.org.junit.Test
* <span class="stReserved">import</span> _root_.org.junit.Before
* <br/><span class="stReserved">class</span> <span class="stType">TwoSuite</span> <span class="stReserved">extends</span> <span class="stType">JUnitSuite</span> {
* <br/> <span class="stReserved">var</span> sb: <span class="stType">StringBuilder</span> = _
* <span class="stReserved">var</span> lb: <span class="stType">ListBuffer[String]</span> = _
* <br/> @<span class="stType">Before</span> <span class="stReserved">def</span> initialize() {
* sb = <span class="stReserved">new</span> <span class="stType">StringBuilder</span>(<span class="stQuotedString">"ScalaTest is "</span>)
* lb = <span class="stReserved">new</span> <span class="stType">ListBuffer[String]</span>
* }
* <br/> @<span class="stType">Test</span> <span class="stReserved">def</span> verifyEasy() {
* sb.append(<span class="stQuotedString">"easy!"</span>)
* assert(sb.toString === <span class="stQuotedString">"ScalaTest is easy!"</span>)
* assert(lb.isEmpty)
* lb += <span class="stQuotedString">"sweet"</span>
* }
* <br/> @<span class="stType">Test</span> <span class="stReserved">def</span> verifyFun() {
* sb.append(<span class="stQuotedString">"fun!"</span>)
* assert(sb.toString === <span class="stQuotedString">"ScalaTest is fun!"</span>)
* assert(lb.isEmpty)
* }
* }
* </pre>
*
* <p>
* To execute <code>JUnitSuite</code>s with ScalaTest's <code>Runner</code>, you must include JUnit 5's jar file on the class path or runpath.
* This version of <code>JUnitSuite</code> was tested with JUnit version 5.9.
* </p>
*
* <p>
* Instances of this class are not thread safe.
* </p>
*
* @author Bill Venners
* @author Daniel Watson
* @author Joel Neely
* @author Chua Chee Seng
*/
class JUnitSuite extends JUnitSuiteLike