/
Ignore.scala
110 lines (104 loc) · 4.8 KB
/
Ignore.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
* Copyright 2001-2013 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.scalatest;
/**
* Annotation used to tag a test, or suite of tests, as ignored.
*
* <p>
* <em>Note: This is actually an annotation defined in Java, not a Scala trait. It must be defined in Java instead of Scala so it will be accessible
* at runtime. It has been inserted into Scaladoc by pretending it is a trait.</em>
* </p>
*
* <p>
* If you wish to temporarily ignore an entire suite of tests, you can annotate the test class with <code>@Ignore</code>, like this:
* </p>
*
* <pre class="stHighlighted">
* <span class="stReserved">package</span> org.scalatest.examples.flatspec.ignoreall
* <br/><span class="stReserved">import</span> org.scalatest._
* <br/>@<span class="stType">Ignore</span>
* <span class="stReserved">class</span> <span class="stType">SetSpec</span> <span class="stReserved">extends</span> <span class="stType">FlatSpec</span> {
* <br/> <span class="stQuotedString">"An empty Set"</span> should <span class="stQuotedString">"have size 0"</span> in {
* assert(Set.empty.size === <span class="stLiteral">0</span>)
* }
* <br/> it should <span class="stQuotedString">"produce NoSuchElementException when head is invoked"</span> in {
* intercept[<span class="stType">NoSuchElementException</span>] {
* Set.empty.head
* }
* }
* }
* </pre>
*
* <p>
* When you mark a test class with a tag annotation, ScalaTest will mark each test defined in that class with that tag.
* Thus, marking the <code>SetSpec</code> in the above example with the <code>@Ignore</code> tag annotation means that both tests
* in the class will be ignored. If you run the above <code>SetSpec</code> in the Scala interpreter, you'll see:
* </p>
*
* <pre class="stREPL">
* scala> org.scalatest.run(new SetSpec)
* <span class="stGreen">An empty Set</span>
* <span class="stYellow">- should have size 0 !!! IGNORED !!!
* - should produce NoSuchElementException when head is invoked !!! IGNORED !!!</span>
* </pre>
*
* <p>
* Note that marking a test class as ignored won't prevent it from being discovered by ScalaTest. Ignored classes
* will be discovered and run, and all their tests will be reported as ignored. This is intended to keep the ignored
* class somewhat visible, to encourage the developers to eventually fix and un-ignore it. If you want to
* prevent a class from being discovered at all, use the <a href="DoNotDiscover.html"><code>DoNotDiscover</code></a> annotation instead.
* </p>
*
* <p>
* Another use case for <code>@Ignore</code> is to mark test <em>methods</em> as ignored in traits <a href="Spec.html"><code>Spec</code></a>
* and <a href="fixture/Spec.html"><code>fixture.Spec</code></a>. Here's an example:
* </p>
*
* <pre class="stHighlighted">
* <span class="stReserved">package</span> org.scalatest.examples.spec.ignore
* <br/><span class="stReserved">import</span> org.scalatest._
* <br/><span class="stReserved">class</span> <span class="stType">SetSpec</span> <span class="stReserved">extends</span> <span class="stType">RefSpec</span> {
* <br/> @<span class="stType">Ignore</span> <span class="stReserved">def</span> <span class="literalIdentifier">`an empty Set should have size 0`</span> {
* assert(Set.empty.size === <span class="stLiteral">0</span>)
* }
* <br/> <span class="stReserved">def</span> <span class="literalIdentifier">`invoking head on an empty Set should produce NoSuchElementException`</span> {
* intercept[<span class="stType">NoSuchElementException</span>] {
* Set.empty.head
* }
* }
* }
* </pre>
*
* <p>
* If you run this version of <code>SetSpec</code> in the Scala interpreter, you'll see that it
* runs only the second test and reports that the first test was ignored:
* </p>
*
* <pre class="stREPL">
* scala> org.scalatest.run(new SetSpec)
* <span class="stGreen">SetSpec:
* <span class="stYellow">- an empty Set should have size 0 !!! IGNORED !!!</span>
* <span class="stGreen">- invoking head on an empty Set should produce NoSuchElementException</span>
* </pre>
*
* <p>
* Note that because reflection is not supported on Scala.js, this annotation will only work on the JVM, not on Scala.js.
* </p>
*
* @author Bill Venners
* @author Chua Chee Seng
*/
trait Ignore extends java.lang.annotation.Annotation