1/* 2 * Copyright 2001-2009 Artima, Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16package org.scalatest.fixture 17 18import org.scalatest._ 19import FixtureNodeFamily._ 20import verb.{ResultOfTaggedAsInvocation, ResultOfStringPassedToVerb, BehaveWord, ShouldVerb, MustVerb, CanVerb} 21import scala.collection.immutable.ListSet 22import org.scalatest.StackDepthExceptionHelper.getStackDepth 23import java.util.concurrent.atomic.AtomicReference 24import java.util.ConcurrentModificationException 25import org.scalatest.events._ 26import Suite.anErrorThatShouldCauseAnAbort 27 28/** 29 * A sister trait to <code>org.scalatest.FlatSpec</code> that can pass a fixture object into its tests. 30 * 31 * <p> 32 * The purpose of <code>FixtureFlatSpec</code> and its subtraits is to facilitate writing tests in 33 * a functional style. Some users may prefer writing tests in a functional style in general, but one 34 * particular use case is parallel test execution (See <a href="../ParallelTestExecution.html">ParallelTestExecution</a>). To run 35 * tests in parallel, your test class must 36 * be thread safe, and a good way to make it thread safe is to make it functional. A good way to 37 * write tests that need common fixtures in a functional style is to pass the fixture objects into the tests, 38 * the style enabled by the <code>FixtureSuite</code> family of traits. 39 * </p> 40 * 41 * <p> 42 * Trait <code>FixtureFlatSpec</code> behaves similarly to trait <code>org.scalatest.FlatSpec</code>, except that tests may have a 43 * fixture parameter. The type of the 44 * fixture parameter is defined by the abstract <code>FixtureParam</code> type, which is declared as a member of this trait. 45 * This trait also declares an abstract <code>withFixture</code> method. This <code>withFixture</code> method 46 * takes a <code>OneArgTest</code>, which is a nested trait defined as a member of this trait. 47 * <code>OneArgTest</code> has an <code>apply</code> method that takes a <code>FixtureParam</code>. 48 * This <code>apply</code> method is responsible for running a test. 49 * This trait's <code>runTest</code> method delegates the actual running of each test to <code>withFixture</code>, passing 50 * in the test code to run via the <code>OneArgTest</code> argument. The <code>withFixture</code> method (abstract in this trait) is responsible 51 * for creating the fixture argument and passing it to the test function. 52 * </p> 53 * 54 * <p> 55 * Subclasses of this trait must, therefore, do three things differently from a plain old <code>org.scalatest.FlatSpec</code>: 56 * </p> 57 * 58 * <ol> 59 * <li>define the type of the fixture parameter by specifying type <code>FixtureParam</code></li> 60 * <li>define the <code>withFixture(OneArgTest)</code> method</li> 61 * <li>write tests that take a fixture parameter</li> 62 * <li>(You can also define tests that don't take a fixture parameter.)</li> 63 * </ol> 64 * 65 * <p> 66 * Here's an example: 67 * </p> 68 * 69 * <pre class="stHighlight"> 70 * import org.scalatest.fixture.FixtureFlatSpec 71 * import collection.mutable.Stack 72 * import java.util.NoSuchElementException 73 * 74 * class StackSpec extends FixtureFlatSpec { 75 * 76 * // 1. define type FixtureParam 77 * type FixtureParam = Stack[Int] 78 * 79 * // 2. define the withFixture method 80 * def withFixture(test: OneArgTest) { 81 * val stack = new Stack[Int] 82 * stack.push(1) 83 * stack.push(2) 84 * test(stack) // "loan" the fixture to the test 85 * } 86 * 87 * // 3. write tests that take a fixture parameter 88 * "A Stack" should "pop a value" in { stack => 89 * val top = stack.pop() 90 * assert(top === 2) 91 * assert(stack.size === 1) 92 * } 93 * 94 * it should "push a value" in { stack => 95 * stack.push(9) 96 * assert(stack.size === 3) 97 * assert(stack.head === 9) 98 * } 99 * 100 * // 4. You can also write tests that don't take a fixture parameter. 101 * it should "complain if popped when empty" in () { 102 * intercept[NoSuchElementException] { 103 * (new Stack[Int]).pop() 104 * } 105 * } 106 * } 107 * </pre> 108 * 109 * <p> 110 * In the previous example, <code>withFixture</code> creates and initializes a stack, then invokes the test function, passing in 111 * the stack. In addition to setting up a fixture before a test, the <code>withFixture</code> method also allows you to 112 * clean it up afterwards, if necessary. If you need to do some clean up that must happen even if a test 113 * fails, you should invoke the test function from inside a <code>try</code> block and do the cleanup in a 114 * <code>finally</code> clause, like this: 115 * </p> 116 * 117 * <pre class="stHighlight"> 118 * def withFixture(test: OneArgTest) { 119 * val resource = someResource.open() // set up the fixture 120 * try { 121 * test(resource) // if the test fails, test(...) will throw an exception 122 * } 123 * finally { 124 * // clean up the fixture no matter whether the test succeeds or fails 125 * resource.close() 126 * } 127 * } 128 * </pre> 129 * 130 * <p> 131 * The reason you must perform cleanup in a <code>finally</code> clause is that <code>withFixture</code> is called by 132 * <code>runTest</code>, which expects an exception to be thrown to indicate a failed test. Thus when you invoke 133 * the <code>test</code> function, it may complete abruptly with an exception. The <code>finally</code> clause will 134 * ensure the fixture cleanup happens as that exception propagates back up the call stack to <code>runTest</code>. 135 * </p> 136 * 137 * <p> 138 * If the fixture you want to pass into your tests consists of multiple objects, you will need to combine 139 * them into one object to use this trait. One good approach to passing multiple fixture objects is 140 * to encapsulate them in a case class. Here's an example: 141 * </p> 142 * 143 * <pre class="stHighlight"> 144 * import org.scalatest.fixture.FixtureFlatSpec 145 * import scala.collection.mutable.ListBuffer 146 * 147 * class ExampleSpec extends FixtureFlatSpec { 148 * 149 * case class F(builder: StringBuilder, buffer: ListBuffer[String]) 150 * type FixtureParam = F 151 * 152 * def withFixture(test: OneArgTest) { 153 * 154 * // Create needed mutable objects 155 * val stringBuilder = new StringBuilder("ScalaTest is ") 156 * val listBuffer = new ListBuffer[String] 157 * 158 * // Invoke the test function, passing in the mutable objects 159 * test(F(stringBuilder, listBuffer)) 160 * } 161 * 162 * "Testing" should "be easy" in { f => 163 * f.builder.append("easy!") 164 * assert(f.builder.toString === "ScalaTest is easy!") 165 * assert(f.buffer.isEmpty) 166 * f.buffer += "sweet" 167 * } 168 * 169 * "Testing" should "be fun" in { f => 170 * f.builder.append("fun!") 171 * assert(f.builder.toString === "ScalaTest is fun!") 172 * assert(f.buffer.isEmpty) 173 * } 174 * } 175 * </pre> 176 * 177 * <h2>Configuring fixtures and tests</h2> 178 * 179 * <p> 180 * Sometimes you may want to write tests that are configurable. For example, you may want to write 181 * a suite of tests that each take an open temp file as a fixture, but whose file name is specified 182 * externally so that the file name can be can be changed from run to run. To accomplish this 183 * the <code>OneArgTest</code> trait has a <code>configMap</code> 184 * method, which will return a <code>Map[String, Any]</code> from which configuration information may be obtained. 185 * The <code>runTest</code> method of this trait will pass a <code>OneArgTest</code> to <code>withFixture</code> 186 * whose <code>configMap</code> method returns the <code>configMap</code> passed to <code>runTest</code>. 187 * Here's an example in which the name of a temp file is taken from the passed <code>configMap</code>: 188 * </p> 189 * 190 * <pre class="stHighlight"> 191 * import org.scalatest.fixture.FixtureFlatSpec 192 * import java.io.FileReader 193 * import java.io.FileWriter 194 * import java.io.File 195 * 196 * class ExampleSpec extends FixtureFlatSpec { 197 * 198 * type FixtureParam = FileReader 199 * def withFixture(test: OneArgTest) { 200 * 201 * require( 202 * test.configMap.contains("TempFileName"), 203 * "This suite requires a TempFileName to be passed in the configMap" 204 * ) 205 * 206 * // Grab the file name from the configMap 207 * val FileName = test.configMap("TempFileName").asInstanceOf[String] 208 * 209 * // Set up the temp file needed by the test 210 * val writer = new FileWriter(FileName) 211 * try { 212 * writer.write("Hello, test!") 213 * } 214 * finally { 215 * writer.close() 216 * } 217 * 218 * // Create the reader needed by the test 219 * val reader = new FileReader(FileName) 220 * 221 * try { 222 * // Run the test using the temp file 223 * test(reader) 224 * } 225 * finally { 226 * // Close and delete the temp file 227 * reader.close() 228 * val file = new File(FileName) 229 * file.delete() 230 * } 231 * } 232 * 233 * "A file" can "be read" in { reader => 234 * var builder = new StringBuilder 235 * var c = reader.read() 236 * while (c != -1) { 237 * builder.append(c.toChar) 238 * c = reader.read() 239 * } 240 * assert(builder.toString === "Hello, test!") 241 * } 242 * 243 * "The first char of a file" can "be read" in { reader => 244 * assert(reader.read() === 'H') 245 * } 246 * } 247 * </pre> 248 * 249 * <p> 250 * If you want to pass into each test the entire <code>configMap</code> that was passed to <code>runTest</code>, you 251 * can mix in trait <code>ConfigMapFixture</code>. See the <a href="ConfigMapFixture.html">documentation 252 * for <code>ConfigMapFixture</code></a> for the details, but here's a quick 253 * example of how it looks: 254 * </p> 255 * 256 * <pre class="stHighlight"> 257 * import org.scalatest.fixture.FixtureFlatSpec 258 * import org.scalatest.fixture.ConfigMapFixture 259 * 260 * class ExampleSpec extends FixtureFlatSpec with ConfigMapFixture { 261 * 262 * "The config map" should "contain hello" in { configMap => 263 * // Use the configMap passed to runTest in the test 264 * assert(configMap.contains("hello")) 265 * } 266 * 267 * it should "contain world" in { configMap => 268 * assert(configMap.contains("world")) 269 * } 270 * } 271 * </pre> 272 * 273 * <h2>Providing multiple fixtures</h2> 274 * 275 * <p> 276 * If different tests in the same <code>FixtureFlatSpec</code> need different shared fixtures, you can use the <em>loan pattern</em> to supply to 277 * each test just the fixture or fixtures it needs. First select the most commonly used fixture objects and pass them in via the 278 * <code>FixtureParam</code>. Then for each remaining fixture needed by multiple tests, create a <em>with<fixture name></em> 279 * method that takes a function you will use to pass the fixture to the test. Lasty, use the appropriate 280 * <em>with<fixture name></em> method or methods in each test. 281 * </p> 282 * 283 * <p> 284 * In the following example, the <code>FixtureParam</code> is set to <code>Map[String, Any]</code> by mixing in <code>ConfigMapFixture</code>. 285 * The <code>withFixture</code> method in trait <code>ConfigMapFixture</code> will pass the config map to any test that needs it. 286 * In addition, some tests in the following example need a <code>Stack[Int]</code> and others a <code>Stack[String]</code>. 287 * The <code>withIntStack</code> method takes 288 * care of supplying the <code>Stack[Int]</code> to those tests that need it, and the <code>withStringStack</code> method takes care 289 * of supplying the <code>Stack[String]</code> fixture. Here's how it looks: 290 * </p> 291 * 292 * <pre class="stHighlight"> 293 * import org.scalatest.fixture.FixtureFlatSpec 294 * import org.scalatest.fixture.ConfigMapFixture 295 * import collection.mutable.Stack 296 * 297 * class StackSpec extends FixtureFlatSpec with ConfigMapFixture { 298 * 299 * def withIntStack(test: Stack[Int] => Any) { 300 * val stack = new Stack[Int] 301 * stack.push(1) 302 * stack.push(2) 303 * test(stack) // "loan" the Stack[Int] fixture to the test 304 * } 305 * 306 * def withStringStack(test: Stack[String] => Any) { 307 * val stack = new Stack[String] 308 * stack.push("one") 309 * stack.push("two") 310 * test(stack) // "loan" the Stack[String] fixture to the test 311 * } 312 * 313 * "A Stack" must "pop an Int value" in { () => // This test doesn't need the configMap fixture, ... 314 * withIntStack { stack => 315 * val top = stack.pop() // But it needs the Stack[Int] fixture. 316 * assert(top === 2) 317 * assert(stack.size === 1) 318 * } 319 * } 320 * 321 * it must "push an Int value" in { configMap => 322 * withIntStack { stack => 323 * val iToPush = // This test uses the configMap fixture... 324 * configMap("IntToPush").toString.toInt 325 * stack.push(iToPush) // And also uses the Stack[Int] fixture. 326 * assert(stack.size === 3) 327 * assert(stack.head === iToPush) 328 * } 329 * } 330 * 331 * it must "pop a String value" in { () => // This test doesn't need the configMap fixture, ... 332 * withStringStack { stack => 333 * val top = stack.pop() // But it needs the Stack[String] fixture. 334 * assert(top === "two") 335 * assert(stack.size === 1) 336 * } 337 * } 338 * 339 * it must "push a String value" in { configMap => 340 * withStringStack { stack => 341 * val sToPush = // This test uses the configMap fixture... 342 * configMap("StringToPush").toString 343 * stack.push(sToPush) // And also uses the Stack[Int] fixture. 344 * assert(stack.size === 3) 345 * assert(stack.head === sToPush) 346 * } 347 * } 348 * } 349 * </pre> 350 * 351 * <p> 352 * If you run the previous class in the Scala interpreter, you'll see: 353 * </p> 354 * 355 * <pre class="stREPL"> 356 * scala> import org.scalatest._ 357 * import org.scalatest._ 358 * 359 * scala> run(new StackSpec, configMap = Map("IntToPush" -> 9, "StringToPush" -> "nine")) 360 * <span class="stGreen">StackSpec: 361 * A Stack 362 * - must pop an Int value 363 * - must push an Int value 364 * - must pop a String value 365 * - must push a String value</span> 366 * </pre> 367 * 368 * @author Bill Venners 369 */ 370trait FixtureFlatSpec extends FixtureSuite with ShouldVerb with MustVerb with CanVerb { thisSuite => 371 372 private final val engine = new FixtureEngine[FixtureParam]("concurrentFixtureFlatSpecMod", "FixtureFlatSpec") 373 import engine._ 374 375 /** 376 * Returns an <code>Informer</code> that during test execution will forward strings (and other objects) passed to its 377 * <code>apply</code> method to the current reporter. If invoked in a constructor, it 378 * will register the passed string for forwarding later during test execution. If invoked while this 379 * <code>FixtureFlatSpec</code> is being executed, such as from inside a test function, it will forward the information to 380 * the current reporter immediately. If invoked at any other time, it will 381 * throw an exception. This method can be called safely by any thread. 382 */ 383 implicit protected def info: Informer = atomicInformer.get 384 385 /** 386 * Register a test with the given spec text, optional tags, and test function value that takes no arguments. 387 * An invocation of this method is called an “example.” 388 * 389 * This method will register the test for later execution via an invocation of one of the <code>execute</code> 390 * methods. The name of the test will be a concatenation of the text of all surrounding describers, 391 * from outside in, and the passed spec text, with one space placed between each item. (See the documenation 392 * for <code>testNames</code> for an example.) The resulting test name must not have been registered previously on 393 * this <code>Spec</code> instance. 394 * 395 * @param specText the specification text, which will be combined with the descText of any surrounding describers 396 * to form the test name 397 * @param testTags the optional list of tags for this test 398 * @param testFun the test function 399 * @throws DuplicateTestNameException if a test with the same name has been registered previously 400 * @throws TestRegistrationClosedException if invoked after <code>run</code> has been invoked on this suite 401 * @throws NullPointerException if <code>specText</code> or any passed test tag is <code>null</code> 402 */ 403 private def registerTestToRun(specText: String, testTags: List[Tag], testFun: FixtureParam => Any) { 404 405 // TODO: This is what was being used before but it is wrong 406 registerTest(specText, testFun, "itCannotAppearInsideAnotherIt", "FixtureFlatSpec.scala", "it", testTags: _*) 407 } 408 409 /** 410 * Class that supports the registration of a “subject” being specified and tested via the 411 * instance referenced from <code>FixtureFlatSpec</code>'s <code>behavior</code> field. 412 * 413 * <p> 414 * This field enables syntax such as the following subject registration: 415 * </p> 416 * 417 * <pre class="stHighlight"> 418 * behavior of "A Stack" 419 * ^ 420 * </pre> 421 * 422 * <p> 423 * For more information and examples of the use of the <code>behavior</code> field, see the <a href="../FlatSpec.html">main documentation</a> 424 * for trait <code>FlatSpec</code>. 425 * </p> 426 */ 427 protected final class BehaviorWord { 428 429 /** 430 * Supports the registration of a “subject” being specified and tested via the 431 * instance referenced from <code>FixtureFlatSpec</code>'s <code>behavior</code> field. 432 * 433 * <p> 434 * This method enables syntax such as the following subject registration: 435 * </p> 436 * 437 * <pre class="stHighlight"> 438 * behavior of "A Stack" 439 * ^ 440 * </pre> 441 * 442 * <p> 443 * For more information and examples of the use of this method, see the <a href="../FlatSpec.html">main documentation</a> 444 * for trait <code>FlatSpec</code>. 445 * </p> 446 */ 447 def of(description: String) { 448 // TODO: This is what was here, but it needs fixing. 449 registerFlatBranch(description, "describeCannotAppearInsideAnIt", "FixtureFlatSpec.scala", "describe") 450 } 451 } 452 453 /** 454 * Supports the registration of a “subject” being specified and tested. 455 * 456 * <p> 457 * This field enables syntax such as the following subject registration: 458 * </p> 459 * 460 * <pre class="stHighlight"> 461 * behavior of "A Stack" 462 * ^ 463 * </pre> 464 * 465 * <p> 466 * For more information and examples of the use of the <code>behavior</code> field, see the <a href="../FlatSpec.html">main documentation</a> 467 * for trait <code>FlatSpec</code>. 468 * </p> 469 */ 470 protected val behavior = new BehaviorWord 471 472 // TODO: Do a walk through. Are all these being used. I guess I'll find out when 473 // I document them. 474 /** 475 * Class that supports the registration of tagged tests via the <code>ItWord</code> instance 476 * referenced from <code>FixtureFlatSpec</code>'s <code>it</code> field. 477 * 478 * <p> 479 * This class enables syntax such as the following tagged test registration: 480 * </p> 481 * 482 * <pre class="stHighlight"> 483 * it should "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 484 * ^ 485 * </pre> 486 * 487 * <p> 488 * It also enables syntax such as the following registration of an ignored, tagged test: 489 * </p> 490 * 491 * <pre class="stHighlight"> 492 * it should "pop values in last-in-first-out order" taggedAs(SlowTest) ignore { ... } 493 * ^ 494 * </pre> 495 * 496 * <p> 497 * In addition, it enables syntax such as the following registration of a pending, tagged test: 498 * </p> 499 * 500 * <pre class="stHighlight"> 501 * it should "pop values in last-in-first-out order" taggedAs(SlowTest) is (pending) 502 * ^ 503 * </pre> 504 * 505 * <p> 506 * For more information and examples of the use of the <code>it</code> field to register tagged tests, see 507 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 508 * </p> 509 */ 510 protected final class ItVerbStringTaggedAs(verb: String, name: String, tags: List[Tag]) { 511 512 /** 513 * Supports the registration of tagged, no-arg tests in a <code>FixtureFlatSpec</code>. 514 * 515 * <p> 516 * This method supports syntax such as the following: 517 * </p> 518 * 519 * <pre class="stHighlight"> 520 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) in { () => ... } 521 * ^ 522 * </pre> 523 * 524 * <p> 525 * For examples of tagged test registration, see 526 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 527 * </p> 528 */ 529 def in(testFun: () => Any) { 530 registerTestToRun(verb + " " + name, tags, new NoArgTestWrapper(testFun)) 531 } 532 533 /** 534 * Supports the registration of tagged, one-arg tests (tests that take a <code>FixtureParam</code> object as a parameter) in a <code>FixtureFlatSpec</code>. 535 * 536 * <p> 537 * This method supports syntax such as the following: 538 * </p> 539 * 540 * <pre class="stHighlight"> 541 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) in { fixture => ... } 542 * ^ 543 * </pre> 544 * 545 * <p> 546 * For examples of tagged test registration, see 547 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 548 * </p> 549 */ 550 def in(testFun: FixtureParam => Any) { 551 registerTestToRun(verb + " " + name, tags, testFun) 552 } 553 554 /** 555 * Supports the registration of pending, tagged tests in a <code>FlatSpec</code>. 556 * 557 * <p> 558 * This method supports syntax such as the following: 559 * </p> 560 * 561 * <pre class="stHighlight"> 562 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) is (pending) 563 * ^ 564 * </pre> 565 * 566 * <p> 567 * For examples of pending test registration, see the <a href="../FlatSpec.html#PendingTests">Pending tests section</a> in the main documentation 568 * for trait <code>FlatSpec</code>. And for examples of tagged test registration, see 569 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 570 * </p> 571 */ 572 def is(testFun: => PendingNothing) { 573 registerTestToRun(verb + " " + name, tags, unusedFixtureParam => testFun) 574 } 575 576 /** 577 * Supports the registration of ignored, tagged, no-arg tests in a <code>FixtureFlatSpec</code>. 578 * 579 * <p> 580 * This method supports syntax such as the following: 581 * </p> 582 * 583 * <pre class="stHighlight"> 584 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) ignore { () => ... } 585 * ^ 586 * </pre> 587 * 588 * <p> 589 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> in the main documentation 590 * for trait <code>FlatSpec</code>. And for examples of tagged test registration, see 591 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 592 * </p> 593 */ 594 def ignore(testFun: () => Any) { 595 registerTestToIgnore(verb + " " + name, tags, new NoArgTestWrapper(testFun)) 596 } 597 598 /** 599 * Supports the registration of ignored, tagged, one-arg tests (tests that take a <code>FixtureParam</code> object 600 * as a parameter) in a <code>FixtureFlatSpec</code>. 601 * 602 * <p> 603 * This method supports syntax such as the following: 604 * </p> 605 * 606 * <pre class="stHighlight"> 607 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) ignore { fixture => ... } 608 * ^ 609 * </pre> 610 * 611 * <p> 612 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> in the main documentation 613 * for trait <code>FlatSpec</code>. And for examples of tagged test registration, see 614 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 615 * </p> 616 */ 617 def ignore(testFun: FixtureParam => Any) { 618 registerTestToIgnore(verb + " " + name, tags, testFun) 619 } 620 } 621 622 /** 623 * Class that supports test registration via the instance referenced from <code>FixtureFlatSpec</code>'s <code>it</code> field. 624 * 625 * <p> 626 * This class enables syntax such as the following test registration: 627 * </p> 628 * 629 * <pre class="stHighlight"> 630 * it should "pop values in last-in-first-out order" in { ... } 631 * ^ 632 * </pre> 633 * 634 * <p> 635 * It also enables syntax such as the following registration of an ignored test: 636 * </p> 637 * 638 * <pre class="stHighlight"> 639 * it should "pop values in last-in-first-out order" ignore { ... } 640 * ^ 641 * </pre> 642 * 643 * <p> 644 * In addition, it enables syntax such as the following registration of a pending test: 645 * </p> 646 * 647 * <pre class="stHighlight"> 648 * it should "pop values in last-in-first-out order" is (pending) 649 * ^ 650 * </pre> 651 * 652 * <p> 653 * And finally, it also enables syntax such as the following tagged test registration: 654 * </p> 655 * 656 * <pre class="stHighlight"> 657 * it should "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 658 * ^ 659 * </pre> 660 * 661 * <p> 662 * For more information and examples of the use of the <code>it</code> field, see the <a href="FixtureFlatSpec.html">main documentation</a> 663 * for trait <code>FixtureFlatSpec</code>. 664 * </p> 665 */ 666 protected final class ItVerbString(verb: String, name: String) { 667 668 /** 669 * Supports the registration of no-arg tests in a <code>FixtureFlatSpec</code>. 670 * 671 * <p> 672 * This method supports syntax such as the following: 673 * </p> 674 * 675 * <pre class="stHighlight"> 676 * it must "pop values in last-in-first-out order" in { () => ... } 677 * ^ 678 * </pre> 679 * 680 * <p> 681 * For examples of no-arg test registration, see the <a href="FixtureFlatSpec.html">main documentation</a> 682 * for trait <code>FixtureFlatSpec</code>. 683 * </p> 684 */ 685 def in(testFun: () => Any) { 686 registerTestToRun(verb + " " + name, List(), new NoArgTestWrapper(testFun)) 687 } 688 689 /** 690 * Supports the registration of one-arg tests (tests that take a <code>FixtureParam</code> object as a parameter) in a <code>FixtureFlatSpec</code>. 691 * 692 * <p> 693 * This method supports syntax such as the following: 694 * </p> 695 * 696 * <pre class="stHighlight"> 697 * it must "pop values in last-in-first-out order" in { fixture => ... } 698 * ^ 699 * </pre> 700 * 701 * <p> 702 * For examples of one-arg test registration, see the <a href="FixtureFlatSpec.html">main documentation</a> 703 * for trait <code>FixtureFlatSpec</code>. 704 * </p> 705 */ 706 def in(testFun: FixtureParam => Any) { 707 registerTestToRun(verb + " " + name, List(), testFun) 708 } 709 710 /** 711 * Supports the registration of pending tests in a <code>FixtureFlatSpec</code>. 712 * 713 * <p> 714 * This method supports syntax such as the following: 715 * </p> 716 * 717 * <pre class="stHighlight"> 718 * it must "pop values in last-in-first-out order" is (pending) 719 * ^ 720 * </pre> 721 * 722 * <p> 723 * For examples of pending test registration, see the <a href="../FlatSpec.html#PendingTests">Pending tests section</a> in the main documentation 724 * for trait <code>FlatSpec</code>. 725 * </p> 726 */ 727 def is(testFun: => PendingNothing) { 728 registerTestToRun(verb + " " + name, List(), unusedFixtureParam => testFun) 729 } 730 731 /** 732 * Supports the registration of ignored no-arg tests in a <code>FixtureFlatSpec</code>. 733 * 734 * <p> 735 * This method supports syntax such as the following: 736 * </p> 737 * 738 * <pre class="stHighlight"> 739 * it must "pop values in last-in-first-out order" ignore { () => ... } 740 * ^ 741 * </pre> 742 * 743 * <p> 744 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> in the main documentation 745 * for trait <code>FlatSpec</code>. 746 * </p> 747 */ 748 def ignore(testFun: () => Any) { 749 registerTestToIgnore(verb + " " + name, List(), new NoArgTestWrapper(testFun)) 750 } 751 752 /** 753 * Supports the registration of ignored one-arg tests (tests that take a <code>FixtureParam</code> object as a parameter) in a <code>FixtureFlatSpec</code>. 754 * 755 * <p> 756 * This method supports syntax such as the following: 757 * </p> 758 * 759 * <pre class="stHighlight"> 760 * it must "pop values in last-in-first-out order" ignore { fixture => ... } 761 * ^ 762 * </pre> 763 * 764 * <p> 765 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> in the main documentation 766 * for trait <code>FlatSpec</code>. 767 * </p> 768 */ 769 def ignore(testFun: FixtureParam => Any) { 770 registerTestToIgnore(verb + " " + name, List(), testFun) 771 } 772 773 /** 774 * Supports the registration of tagged tests in a <code>FixtureFlatSpec</code>. 775 * 776 * <p> 777 * This method supports syntax such as the following: 778 * </p> 779 * 780 * <pre class="stHighlight"> 781 * it must "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 782 * ^ 783 * </pre> 784 * 785 * <p> 786 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation 787 * for trait <code>FlatSpec</code>. 788 * </p> 789 */ 790 def taggedAs(firstTestTag: Tag, otherTestTags: Tag*) = { 791 val tagList = firstTestTag :: otherTestTags.toList 792 new ItVerbStringTaggedAs(verb, name, tagList) 793 } 794 } 795 796 /** 797 * Class that supports test (and shared test) registration via the instance referenced from <code>FixtureFlatSpec</code>'s <code>it</code> field. 798 * 799 * <p> 800 * This class enables syntax such as the following test registration: 801 * </p> 802 * 803 * <pre class="stHighlight"> 804 * it should "pop values in last-in-first-out order" in { ... } 805 * ^ 806 * </pre> 807 * 808 * <p> 809 * It also enables syntax such as the following shared test registration: 810 * </p> 811 * 812 * <pre class="stHighlight"> 813 * it should behave like nonEmptyStack(lastItemPushed) 814 * ^ 815 * </pre> 816 * 817 * <p> 818 * For more information and examples of the use of the <code>it</code> field, see the main documentation 819 * for trait <a href="../FlatSpec.html"><code>FlatSpec</code></a>. 820 * </p> 821 */ 822 protected final class ItWord { 823 824 /** 825 * Supports the registration of tests with <code>should</code> in a <code>FixtureFlatSpec</code>. 826 * 827 * <p> 828 * This method supports syntax such as the following: 829 * </p> 830 * 831 * <pre class="stHighlight"> 832 * it should "pop values in last-in-first-out order" in { ... } 833 * ^ 834 * </pre> 835 * 836 * <p> 837 * For examples of test registration, see the <a href="../FlatSpec.html">main documentation</a> 838 * for trait <code>FlatSpec</code>. 839 * </p> 840 */ 841 def should(string: String) = new ItVerbString("should", string) 842 843 /** 844 * Supports the registration of tests with <code>must</code> in a <code>FixtureFlatSpec</code>. 845 * 846 * <p> 847 * This method supports syntax such as the following: 848 * </p> 849 * 850 * <pre class="stHighlight"> 851 * it must "pop values in last-in-first-out order" in { ... } 852 * ^ 853 * </pre> 854 * 855 * <p> 856 * For examples of test registration, see the <a href="../FlatSpec.html">main documentation</a> 857 * for trait <code>FlatSpec</code>. 858 * </p> 859 */ 860 def must(string: String) = new ItVerbString("must", string) 861 862 /** 863 * Supports the registration of tests with <code>can</code> in a <code>FixtureFlatSpec</code>. 864 * 865 * <p> 866 * This method supports syntax such as the following: 867 * </p> 868 * 869 * <pre class="stHighlight"> 870 * it can "pop values in last-in-first-out order" in { ... } 871 * ^ 872 * </pre> 873 * 874 * <p> 875 * For examples of test registration, see the <a href="../FlatSpec.html">main documentation</a> 876 * for trait <code>FlatSpec</code>. 877 * </p> 878 */ 879 def can(string: String) = new ItVerbString("can", string) 880 881 /** 882 * Supports the registration of shared tests with <code>should</code> in a <code>FixtureFlatSpec</code>. 883 * 884 * <p> 885 * This method supports syntax such as the following: 886 * </p> 887 * 888 * <pre class="stHighlight"> 889 * it should behave like nonFullStack(stackWithOneItem) 890 * ^ 891 * </pre> 892 * 893 * <p> 894 * For examples of shared tests, see the <a href="../FlatSpec.html#SharedTests">Shared tests section</a> 895 * in the main documentation for trait <code>FlatSpec</code>. 896 * </p> 897 */ 898 def should(behaveWord: BehaveWord) = behaveWord 899 900 /** 901 * Supports the registration of shared tests with <code>must</code> in a <code>FixtureFlatSpec</code>. 902 * 903 * <p> 904 * This method supports syntax such as the following: 905 * </p> 906 * 907 * <pre class="stHighlight"> 908 * it must behave like nonFullStack(stackWithOneItem) 909 * ^ 910 * </pre> 911 * 912 * <p> 913 * For examples of shared tests, see the <a href="../FlatSpec.html#SharedTests">Shared tests section</a> 914 * in the main documentation for trait <code>FlatSpec</code>. 915 * </p> 916 */ 917 def must(behaveWord: BehaveWord) = behaveWord 918 919 /** 920 * Supports the registration of shared tests with <code>can</code> in a <code>FixtureFlatSpec</code>. 921 * 922 * <p> 923 * This method supports syntax such as the following: 924 * </p> 925 * 926 * <pre class="stHighlight"> 927 * it can behave like nonFullStack(stackWithOneItem) 928 * ^ 929 * </pre> 930 * 931 * <p> 932 * For examples of shared tests, see the <a href="../FlatSpec.html#SharedTests">Shared tests section</a> 933 * in the main documentation for trait <code>FlatSpec</code>. 934 * </p> 935 */ 936 def can(behaveWord: BehaveWord) = behaveWord 937 } 938 939 /** 940 * Supports test (and shared test) registration in <code>FixtureFlatSpec</code>s. 941 * 942 * <p> 943 * This field enables syntax such as the following test registration: 944 * </p> 945 * 946 * <pre class="stHighlight"> 947 * it should "pop values in last-in-first-out order" in { ... } 948 * ^ 949 * </pre> 950 * 951 * <p> 952 * It also enables syntax such as the following shared test registration: 953 * </p> 954 * 955 * <pre class="stHighlight"> 956 * it should behave like nonEmptyStack(lastItemPushed) 957 * ^ 958 * </pre> 959 * 960 * <p> 961 * For more information and examples of the use of the <code>it</code> field, see the main documentation 962 * for trait <a href="../FlatSpec.html"><code>FlatSpec</code></a>. 963 * </p> 964 */ 965 protected val it = new ItWord 966 967 /** 968 * Class that supports registration of ignored, tagged tests via the <code>IgnoreWord</code> instance referenced 969 * from <code>FixtureFlatSpec</code>'s <code>ignore</code> field. 970 * 971 * <p> 972 * This class enables syntax such as the following registration of an ignored, tagged test: 973 * </p> 974 * 975 * <pre class="stHighlight"> 976 * ignore should "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 977 * ^ 978 * </pre> 979 * 980 * <p> 981 * In addition, it enables syntax such as the following registration of an ignored, tagged, pending test: 982 * </p> 983 * 984 * <pre class="stHighlight"> 985 * ignore should "pop values in last-in-first-out order" taggedAs(SlowTest) is (pending) 986 * ^ 987 * </pre> 988 * 989 * <p> 990 * Note: the <code>is</code> method is provided for completeness and design symmetry, given there's no way 991 * to prevent changing <code>is</code> to <code>ignore</code> and marking a pending test as ignored that way. 992 * Although it isn't clear why someone would want to mark a pending test as ignored, it can be done. 993 * </p> 994 * 995 * <p> 996 * For more information and examples of the use of the <code>ignore</code> field, see 997 * the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 998 * in the main documentation for trait <code>FlatSpec</code>. For examples of tagged test registration, see 999 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 1000 * </p> 1001 */ 1002 protected final class IgnoreVerbStringTaggedAs(verb: String, name: String, tags: List[Tag]) { 1003 1004 /** 1005 * Supports the registration of ignored, tagged, no-arg tests in a <code>FixtureFlatSpec</code>. 1006 * 1007 * <p> 1008 * This method supports syntax such as the following: 1009 * </p> 1010 * 1011 * <pre class="stHighlight"> 1012 * ignore must "pop values in last-in-first-out order" taggedAs(SlowTest) in { () => ... } 1013 * ^ 1014 * </pre> 1015 * 1016 * <p> 1017 * For examples of the registration of ignored tests, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1018 * in the main documentation for trait <code>FlatSpec</code>. For examples of tagged test registration, see 1019 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 1020 * </p> 1021 */ 1022 def in(testFun: () => Any) { 1023 registerTestToIgnore(verb + " " + name, tags, new NoArgTestWrapper(testFun)) 1024 } 1025 1026 /** 1027 * Supports the registration of ignored, tagged, one-arg tests (tests that take a <code>FixtureParam</code> object as a parameter) 1028 * in a <code>FixtureFlatSpec</code>. 1029 * 1030 * <p> 1031 * This method supports syntax such as the following: 1032 * </p> 1033 * 1034 * <pre class="stHighlight"> 1035 * ignore must "pop values in last-in-first-out order" taggedAs(SlowTest) in { fixture => ... } 1036 * ^ 1037 * </pre> 1038 * 1039 * <p> 1040 * For examples of the registration of ignored tests, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1041 * in the main documentation for trait <code>FlatSpec</code>. For examples of tagged test registration, see 1042 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 1043 * </p> 1044 */ 1045 def in(testFun: FixtureParam => Any) { 1046 registerTestToIgnore(verb + " " + name, tags, testFun) 1047 } 1048 1049 /** 1050 * Supports the registration of ignored, tagged, pending tests in a <code>FixtureFlatSpec</code>. 1051 * 1052 * <p> 1053 * This method supports syntax such as the following: 1054 * </p> 1055 * 1056 * <pre class="stHighlight"> 1057 * ignore must "pop values in last-in-first-out order" taggedAs(SlowTest) is (pending) 1058 * ^ 1059 * </pre> 1060 * 1061 * <p> 1062 * Note: this <code>is</code> method is provided for completeness and design symmetry, given there's no way 1063 * to prevent changing <code>is</code> to <code>ignore</code> and marking a pending test as ignored that way. 1064 * Although it isn't clear why someone would want to mark a pending test as ignored, it can be done. 1065 * </p> 1066 * 1067 * <p> 1068 * For examples of pending test registration, see the <a href="../FlatSpec.html#PendingTests">Pending tests section</a> in the main documentation 1069 * for trait <code>FlatSpec</code>. For examples of the registration of ignored tests, 1070 * see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1071 * in the main documentation for trait <code>FlatSpec</code>. For examples of tagged test registration, see 1072 * the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation for trait <code>FlatSpec</code>. 1073 * </p> 1074 */ 1075 def is(testFun: => PendingNothing) { 1076 registerTestToIgnore(verb + " " + name, tags, unusedFixtureParam => testFun) 1077 } 1078 } 1079 1080 /** 1081 * Class that supports registration of ignored tests via the <code>IgnoreWord</code> instance referenced 1082 * from <code>FixtureFlatSpec</code>'s <code>ignore</code> field. 1083 * 1084 * <p> 1085 * This class enables syntax such as the following registration of an ignored test: 1086 * </p> 1087 * 1088 * <pre class="stHighlight"> 1089 * ignore should "pop values in last-in-first-out order" in { ... } 1090 * ^ 1091 * </pre> 1092 * 1093 * <p> 1094 * In addition, it enables syntax such as the following registration of an ignored, pending test: 1095 * </p> 1096 * 1097 * <pre class="stHighlight"> 1098 * ignore should "pop values in last-in-first-out order" is (pending) 1099 * ^ 1100 * </pre> 1101 * 1102 * Note: the <code>is</code> method is provided for completeness and design symmetry, given there's no way 1103 * to prevent changing <code>is</code> to <code>ignore</code> and marking a pending test as ignored that way. 1104 * Although it isn't clear why someone would want to mark a pending test as ignored, it can be done. 1105 * </p> 1106 * 1107 * <p> 1108 * And finally, it also enables syntax such as the following ignored, tagged test registration: 1109 * </p> 1110 * 1111 * <pre class="stHighlight"> 1112 * ignore should "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 1113 * ^ 1114 * </pre> 1115 * 1116 * <p> 1117 * <p> 1118 * For more information and examples of the use of the <code>ignore</code> field, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1119 * in the main documentation for trait <code>FlatSpec</code>. 1120 * </p> 1121 */ 1122 protected final class IgnoreVerbString(verb: String, name: String) { 1123 1124 /** 1125 * Supports the registration of ignored, no-arg tests in a <code>FixtureFlatSpec</code>. 1126 * 1127 * <p> 1128 * This method supports syntax such as the following: 1129 * </p> 1130 * 1131 * <pre class="stHighlight"> 1132 * ignore must "pop values in last-in-first-out order" in { () => ... } 1133 * ^ 1134 * </pre> 1135 * 1136 * <p> 1137 * For examples of the registration of ignored tests, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1138 * in the main documentation for trait <code>FlatSpec</code>. 1139 * </p> 1140 */ 1141 def in(testFun: () => Any) { 1142 registerTestToIgnore(verb + " " + name, List(), new NoArgTestWrapper(testFun)) 1143 } 1144 1145 /** 1146 * Supports the registration of ignored, one-arg tests (tests that take a <code>FixtureParam</code> object 1147 * as a parameter) in a <code>FixtureFlatSpec</code>. 1148 * 1149 * <p> 1150 * This method supports syntax such as the following: 1151 * </p> 1152 * 1153 * <pre class="stHighlight"> 1154 * ignore must "pop values in last-in-first-out order" in { fixture => ... } 1155 * ^ 1156 * </pre> 1157 * 1158 * <p> 1159 * For examples of the registration of ignored tests, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1160 * in the main documentation for trait <code>FlatSpec</code>. 1161 * </p> 1162 */ 1163 def in(testFun: FixtureParam => Any) { 1164 registerTestToIgnore(verb + " " + name, List(), testFun) 1165 } 1166 1167 /** 1168 * Supports the registration of ignored, pending tests in a <code>FixtureFlatSpec</code>. 1169 * 1170 * <p> 1171 * This method supports syntax such as the following: 1172 * </p> 1173 * 1174 * <pre class="stHighlight"> 1175 * ignore must "pop values in last-in-first-out order" is (pending) 1176 * ^ 1177 * </pre> 1178 * 1179 * <p> 1180 * Note: this <code>is</code> method is provided for completeness and design symmetry, given there's no way 1181 * to prevent changing <code>is</code> to <code>ignore</code> and marking a pending test as ignored that way. 1182 * Although it isn't clear why someone would want to mark a pending test as ignored, it can be done. 1183 * </p> 1184 * 1185 * <p> 1186 * For examples of pending test registration, see the <a href="../FlatSpec.html#PendingTests">Pending tests section</a> in the main documentation 1187 * for trait <code>FlatSpec</code>. For examples of the registration of ignored tests, 1188 * see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1189 * in the main documentation for trait <code>FlatSpec</code>. 1190 * </p> 1191 */ 1192 def is(testFun: => PendingNothing) { 1193 registerTestToIgnore(verb + " " + name, List(), unusedFixtureParam => testFun) 1194 } 1195 1196 /** 1197 * Supports the registration of ignored, tagged tests in a <code>FixtureFlatSpec</code>. 1198 * 1199 * <p> 1200 * This method supports syntax such as the following: 1201 * </p> 1202 * 1203 * <pre class="stHighlight"> 1204 * ignore must "pop values in last-in-first-out order" taggedAs(SlowTest) in { ... } 1205 * ^ 1206 * </pre> 1207 * 1208 * <p> 1209 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> in the main documentation 1210 * for trait <code>FlatSpec</code>. For examples of the registration of ignored tests, 1211 * see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1212 * in the main documentation for trait <code>FlatSpec</code>. 1213 * </p> 1214 */ 1215 def taggedAs(firstTestTag: Tag, otherTestTags: Tag*) = { 1216 val tagList = firstTestTag :: otherTestTags.toList 1217 new IgnoreVerbStringTaggedAs(verb, name, tagList) 1218 } 1219 } 1220 1221 /** 1222 * Class that supports registration of ignored tests via the instance referenced from <code>FixtureFlatSpec</code>'s <code>ignore</code> field. 1223 * 1224 * <p> 1225 * This class enables syntax such as the following registration of an ignored test: 1226 * </p> 1227 * 1228 * <pre class="stHighlight"> 1229 * ignore should "pop values in last-in-first-out order" in { ... } 1230 * ^ 1231 * </pre> 1232 * 1233 * <p> 1234 * For more information and examples of the use of the <code>ignore</code> field, see <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1235 * in the main documentation for this trait. 1236 * </p> 1237 */ 1238 protected final class IgnoreWord { 1239 1240 /** 1241 * Supports the registration of ignored tests with <code>should</code> in a <code>FixtureFlatSpec</code>. 1242 * 1243 * <p> 1244 * This method supports syntax such as the following: 1245 * </p> 1246 * 1247 * <pre class="stHighlight"> 1248 * ignore should "pop values in last-in-first-out order" in { ... } 1249 * ^ 1250 * </pre> 1251 * 1252 * <p> 1253 * For more information and examples of the use of the <code>ignore</code> field, see <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1254 * in the main documentation for trait <code>FlatSpec</code>. 1255 * </p> 1256 */ 1257 def should(string: String) = new IgnoreVerbString("should", string) 1258 1259 /** 1260 * Supports the registration of ignored tests with <code>must</code> in a <code>FixtureFlatSpec</code>. 1261 * 1262 * <p> 1263 * This method supports syntax such as the following: 1264 * </p> 1265 * 1266 * <pre class="stHighlight"> 1267 * ignore must "pop values in last-in-first-out order" in { ... } 1268 * ^ 1269 * </pre> 1270 * 1271 * <p> 1272 * For more information and examples of the use of the <code>ignore</code> field, see <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1273 * in the main documentation for trait <code>FlatSpec</code>. 1274 * </p> 1275 */ 1276 def must(string: String) = new IgnoreVerbString("must", string) 1277 1278 /** 1279 * Supports the registration of ignored tests with <code>can</code> in a <code>FixtureFlatSpec</code>. 1280 * 1281 * <p> 1282 * This method supports syntax such as the following: 1283 * </p> 1284 * 1285 * <pre class="stHighlight"> 1286 * ignore can "pop values in last-in-first-out order" in { ... } 1287 * ^ 1288 * </pre> 1289 * 1290 * <p> 1291 * For more information and examples of the use of the <code>ignore</code> field, see <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1292 * in the main documentation for trait <code>FlatSpec</code>. 1293 * </p> 1294 */ 1295 def can(string: String) = new IgnoreVerbString("can", string) 1296 } 1297 1298 /** 1299 * Supports registration of ignored tests in <code>FixtureFlatSpec</code>s. 1300 * 1301 * <p> 1302 * This field enables syntax such as the following registration of an ignored test: 1303 * </p> 1304 * 1305 * <pre class="stHighlight"> 1306 * ignore should "pop values in last-in-first-out order" in { ... } 1307 * ^ 1308 * </pre> 1309 * 1310 * <p> 1311 * For more information and examples of the use of the <code>ignore</code> field, see the 1312 * <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> in the main documentation for trait <code>FlatSpec</code>. 1313 * </p> 1314 */ 1315 protected val ignore = new IgnoreWord 1316 1317 /** 1318 * Class that supports test registration in shorthand form. 1319 * 1320 * <p> 1321 * For example, this class enables syntax such as the following test registration 1322 * in shorthand form: 1323 * </p> 1324 * 1325 * <pre class="stHighlight"> 1326 * "A Stack (when empty)" should "be empty" in { ... } 1327 * ^ 1328 * </pre> 1329 * 1330 * <p> 1331 * This class also enables syntax such as the following ignored test registration 1332 * in shorthand form: 1333 * </p> 1334 * 1335 * <pre class="stHighlight"> 1336 * "A Stack (when empty)" should "be empty" ignore { ... } 1337 * ^ 1338 * </pre> 1339 * 1340 * <p> 1341 * This class is used via an implicit conversion (named <code>convertToInAndIgnoreMethods</code>) 1342 * from <code>ResultOfStringPassedToVerb</code>. The <code>ResultOfStringPassedToVerb</code> class 1343 * does not declare any methods named <code>in</code>, because the 1344 * type passed to <code>in</code> differs in a <code>FlatSpec</code> and a <code>FixtureFlatSpec</code>. 1345 * A <code>FixtureFlatSpec</code> needs two <code>in</code> methods, one that takes a no-arg 1346 * test function and another that takes a one-arg test function (a test that takes a 1347 * <code>FixtureParam</code> as its parameter). By constrast, a <code>FlatSpec</code> needs 1348 * only one <code>in</code> method that takes a by-name parameter. As a result, 1349 * <code>FlatSpec</code> and <code>FixtureFlatSpec</code> each provide an implicit conversion 1350 * from <code>ResultOfStringPassedToVerb</code> to a type that provides the appropriate 1351 * <code>in</code> methods. 1352 * </p> 1353 * 1354 * @author Bill Venners 1355 */ 1356 protected final class InAndIgnoreMethods(resultOfStringPassedToVerb: ResultOfStringPassedToVerb) { 1357 1358 import resultOfStringPassedToVerb.verb 1359 import resultOfStringPassedToVerb.rest 1360 1361 /** 1362 * Supports the registration of no-arg tests in shorthand form. 1363 * 1364 * <p> 1365 * This method supports syntax such as the following: 1366 * </p> 1367 * 1368 * <pre class="stHighlight"> 1369 * "A Stack" must "pop values in last-in-first-out order" in { () => ... } 1370 * ^ 1371 * </pre> 1372 * 1373 * <p> 1374 * For examples of test registration, see the <a href="FixtureFlatSpec.html">main documentation</a> 1375 * for trait <code>FixtureFlatSpec</code>. 1376 * </p> 1377 */ 1378 def in(testFun: () => Any) { 1379 registerTestToRun(verb + " " + rest, List(), new NoArgTestWrapper(testFun)) 1380 } 1381 1382 /** 1383 * Supports the registration of ignored, no-arg tests in shorthand form. 1384 * 1385 * <p> 1386 * This method supports syntax such as the following: 1387 * </p> 1388 * 1389 * <pre class="stHighlight"> 1390 * "A Stack" must "pop values in last-in-first-out order" ignore { () => ... } 1391 * ^ 1392 * </pre> 1393 * 1394 * <p> 1395 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1396 * in the main documentation for trait <code>FlatSpec</code>. 1397 * </p> 1398 */ 1399 def ignore(testFun: () => Any) { 1400 registerTestToIgnore(verb + " " + rest, List(), new NoArgTestWrapper(testFun)) 1401 } 1402 1403 /** 1404 * Supports the registration of one-arg tests (tests that take a <code>FixtureParam</code> parameter) in shorthand form. 1405 * 1406 * <p> 1407 * This method supports syntax such as the following: 1408 * </p> 1409 * 1410 * <pre class="stHighlight"> 1411 * "A Stack" must "pop values in last-in-first-out order" in { fixture => ... } 1412 * ^ 1413 * </pre> 1414 * 1415 * <p> 1416 * For examples of test registration, see the <a href="FixtureFlatSpec.html">main documentation</a> 1417 * for trait <code>FixtureFlatSpec</code>. 1418 * </p> 1419 */ 1420 def in(testFun: FixtureParam => Any) { 1421 registerTestToRun(verb + " " + rest, List(), testFun) 1422 } 1423 1424 /** 1425 * Supports the registration of ignored, one-arg tests (tests that take a <code>FixtureParam</code> parameter) in shorthand form. 1426 * 1427 * <p> 1428 * This method supports syntax such as the following: 1429 * </p> 1430 * 1431 * <pre class="stHighlight"> 1432 * "A Stack" must "pop values in last-in-first-out order" ignore { fixture => ... } 1433 * ^ 1434 * </pre> 1435 * 1436 * <p> 1437 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1438 * in the main documentation for trait <code>FlatSpec</code>. 1439 * </p> 1440 */ 1441 def ignore(testFun: FixtureParam => Any) { 1442 registerTestToIgnore(verb + " " + rest, List(), testFun) 1443 } 1444 } 1445 1446 /** 1447 * Implicitly converts an object of type <code>ResultOfStringPassedToVerb</code> to an 1448 * <code>InAndIgnoreMethods</code>, to enable <code>in</code> and <code>ignore</code> 1449 * methods to be invokable on that object. 1450 */ 1451 protected implicit def convertToInAndIgnoreMethods(resultOfStringPassedToVerb: ResultOfStringPassedToVerb) = 1452 new InAndIgnoreMethods(resultOfStringPassedToVerb) 1453 1454 /** 1455 * Class that supports tagged test registration in shorthand form. 1456 * 1457 * <p> 1458 * For example, this class enables syntax such as the following tagged test registration 1459 * in shorthand form: 1460 * </p> 1461 * 1462 * <pre class="stHighlight"> 1463 * "A Stack (when empty)" should "be empty" taggedAs() in { ... } 1464 * ^ 1465 * </pre> 1466 * 1467 * <p> 1468 * This class also enables syntax such as the following tagged, ignored test registration 1469 * in shorthand form: 1470 * </p> 1471 * 1472 * <pre class="stHighlight"> 1473 * "A Stack (when empty)" should "be empty" taggedAs(SlowTest) ignore { ... } 1474 * ^ 1475 * </pre> 1476 * 1477 * <p> 1478 * This class is used via an implicit conversion (named <code>convertToInAndIgnoreMethodsAfterTaggedAs</code>) 1479 * from <code>ResultOfTaggedAsInvocation</code>. The <code>ResultOfTaggedAsInvocation</code> class 1480 * does not declare any methods named <code>in</code>, because the 1481 * type passed to <code>in</code> differs in a <code>FlatSpec</code> and a <code>FixtureFlatSpec</code>. 1482 * A <code>FixtureFlatSpec</code> needs two <code>in</code> methods, one that takes a no-arg 1483 * test function and another that takes a one-arg test function (a test that takes a 1484 * <code>FixtureParam</code> as its parameter). By constrast, a <code>FlatSpec</code> needs 1485 * only one <code>in</code> method that takes a by-name parameter. As a result, 1486 * <code>FlatSpec</code> and <code>FixtureFlatSpec</code> each provide an implicit conversion 1487 * from <code>ResultOfTaggedAsInvocation</code> to a type that provides the appropriate 1488 * <code>in</code> methods. 1489 * </p> 1490 * 1491 * @author Bill Venners 1492 */ 1493 protected final class InAndIgnoreMethodsAfterTaggedAs(resultOfTaggedAsInvocation: ResultOfTaggedAsInvocation) { 1494 1495 import resultOfTaggedAsInvocation.verb 1496 import resultOfTaggedAsInvocation.rest 1497 import resultOfTaggedAsInvocation.{tags => tagsList} 1498 1499 /** 1500 * Supports the registration of tagged, no-arg tests in shorthand form. 1501 * 1502 * <p> 1503 * This method supports syntax such as the following: 1504 * </p> 1505 * 1506 * <pre class="stHighlight"> 1507 * "A Stack" must "pop values in last-in-first-out order" taggedAs(SlowTest) in { () => ... } 1508 * ^ 1509 * </pre> 1510 * 1511 * <p> 1512 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> 1513 * in the main documentation for trait <code>FlatSpec</code>. 1514 * </p> 1515 */ 1516 def in(testFun: () => Any) { 1517 registerTestToRun(verb + " " + rest, tagsList, new NoArgTestWrapper(testFun)) 1518 } 1519 1520 /** 1521 * Supports the registration of tagged, ignored, no-arg tests in shorthand form. 1522 * 1523 * <p> 1524 * This method supports syntax such as the following: 1525 * </p> 1526 * 1527 * <pre class="stHighlight"> 1528 * "A Stack" must "pop values in last-in-first-out order" taggedAs(SlowTest) ignore { () => ... } 1529 * ^ 1530 * </pre> 1531 * 1532 * <p> 1533 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1534 * in the main documentation for trait <code>FlatSpec</code>. 1535 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> 1536 * in the main documentation for trait <code>FlatSpec</code>. 1537 * </p> 1538 */ 1539 def ignore(testFun: () => Any) { 1540 registerTestToIgnore(verb + " " + rest, tagsList, new NoArgTestWrapper(testFun)) 1541 } 1542 1543 /** 1544 * Supports the registration of tagged, one-arg tests (tests that take a <code>FixtureParam</code> parameter) in shorthand form. 1545 * 1546 * <p> 1547 * This method supports syntax such as the following: 1548 * </p> 1549 * 1550 * <pre class="stHighlight"> 1551 * "A Stack" must "pop values in last-in-first-out order" taggedAs(SlowTest) in { fixture => ... } 1552 * ^ 1553 * </pre> 1554 * 1555 * <p> 1556 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> 1557 * in the main documentation for trait <code>FlatSpec</code>. 1558 * </p> 1559 */ 1560 def in(testFun: FixtureParam => Any) { 1561 registerTestToRun(verb + " " + rest, tagsList, testFun) 1562 } 1563 1564 /** 1565 * Supports the registration of tagged, ignored, one-arg tests (tests that take a <code>FixtureParam</code> parameter) in shorthand form. 1566 * 1567 * <p> 1568 * This method supports syntax such as the following: 1569 * </p> 1570 * 1571 * <pre class="stHighlight"> 1572 * "A Stack" must "pop values in last-in-first-out order" taggedAs(SlowTest) ignore { fixture => ... } 1573 * ^ 1574 * </pre> 1575 * 1576 * <p> 1577 * For examples of ignored test registration, see the <a href="../FlatSpec.html#IgnoredTests">Ignored tests section</a> 1578 * in the main documentation for trait <code>FlatSpec</code>. 1579 * For examples of tagged test registration, see the <a href="../FlatSpec.html#TaggingTests">Tagging tests section</a> 1580 * in the main documentation for trait <code>FlatSpec</code>. 1581 * </p> 1582 */ 1583 def ignore(testFun: FixtureParam => Any) { 1584 registerTestToIgnore(verb + " " + rest, tagsList, testFun) 1585 } 1586 } 1587 1588 /** 1589 * Implicitly converts an object of type <code>ResultOfTaggedAsInvocation</code> to an 1590 * <code>InAndIgnoreMethodsAfterTaggedAs</code>, to enable <code>in</code> and <code>ignore</code> 1591 * methods to be invokable on that object. 1592 */ 1593 protected implicit def convertToInAndIgnoreMethodsAfterTaggedAs(resultOfTaggedAsInvocation: ResultOfTaggedAsInvocation) = 1594 new InAndIgnoreMethodsAfterTaggedAs(resultOfTaggedAsInvocation) 1595 1596 /** 1597 * Supports the shorthand form of test registration. 1598 * 1599 * <p> 1600 * For example, this method enables syntax such as the following: 1601 * </p> 1602 * 1603 * <pre class="stHighlight"> 1604 * "A Stack (when empty)" should "be empty" in { ... } 1605 * ^ 1606 * </pre> 1607 * 1608 * <p> 1609 * This function is passed as an implicit parameter to a <code>should</code> method 1610 * provided in <code>ShouldVerb</code>, a <code>must</code> method 1611 * provided in <code>MustVerb</code>, and a <code>can</code> method 1612 * provided in <code>CanVerb</code>. When invoked, this function registers the 1613 * subject description (the first parameter to the function) and returns a <code>ResultOfStringPassedToVerb</code> 1614 * initialized with the verb and rest parameters (the second and third parameters to 1615 * the function, respectively). 1616 * </p> 1617 */ 1618 protected implicit val shorthandTestRegistrationFunction: (String, String, String) => ResultOfStringPassedToVerb = { 1619 (subject, verb, rest) => { 1620 behavior.of(subject) 1621 new ResultOfStringPassedToVerb(verb, rest) { 1622 def is(testFun: => PendingNothing) { 1623 registerTestToRun(verb + " " + rest, List(), unusedFixtureParam => testFun) 1624 } 1625 def taggedAs(firstTestTag: Tag, otherTestTags: Tag*) = { 1626 val tagList = firstTestTag :: otherTestTags.toList 1627 new ResultOfTaggedAsInvocation(verb, rest, tagList) { 1628 // "A Stack" must "test this" taggedAs(mytags.SlowAsMolasses) is (pending) 1629 // ^ 1630 def is(testFun: => PendingNothing) { 1631 registerTestToRun(verb + " " + rest, tags, new NoArgTestWrapper(testFun _)) 1632 } 1633 } 1634 } 1635 } 1636 } 1637 } 1638 1639 // TODO: Get rid of unusedfixture, and use NoArgTestFunction instead 1640 1641 /** 1642 * Supports the shorthand form of shared test registration. 1643 * 1644 * <p> 1645 * For example, this method enables syntax such as the following: 1646 * </p> 1647 * 1648 * <pre class="stHighlight"> 1649 * "A Stack (with one item)" should behave like nonEmptyStack(stackWithOneItem, lastValuePushed) 1650 * ^ 1651 * </pre> 1652 * 1653 * <p> 1654 * This function is passed as an implicit parameter to a <code>should</code> method 1655 * provided in <code>ShouldVerb</code>, a <code>must</code> method 1656 * provided in <code>MustVerb</code>, and a <code>can</code> method 1657 * provided in <code>CanVerb</code>. When invoked, this function registers the 1658 * subject description (the parameter to the function) and returns a <code>BehaveWord</code>. 1659 * </p> 1660 */ 1661 protected implicit val shorthandSharedTestRegistrationFunction: (String) => BehaveWord = { 1662 (left) => { 1663 behavior.of(left) 1664 new BehaveWord 1665 } 1666 } 1667 1668 /** 1669 * Register a test to ignore, which has the given spec text, optional tags, and test function value that takes no arguments. 1670 * This method will register the test for later ignoring via an invocation of one of the <code>execute</code> 1671 * methods. This method exists to make it easy to ignore an existing test by changing the call to <code>it</code> 1672 * to <code>ignore</code> without deleting or commenting out the actual test code. The test will not be executed, but a 1673 * report will be sent that indicates the test was ignored. The name of the test will be a concatenation of the text of all surrounding describers, 1674 * from outside in, and the passed spec text, with one space placed between each item. (See the documenation 1675 * for <code>testNames</code> for an example.) The resulting test name must not have been registered previously on 1676 * this <code>Spec</code> instance. 1677 * 1678 * @param specText the specification text, which will be combined with the descText of any surrounding describers 1679 * to form the test name 1680 * @param testTags the optional list of tags for this test 1681 * @param testFun the test function 1682 * @throws DuplicateTestNameException if a test with the same name has been registered previously 1683 * @throws TestRegistrationClosedException if invoked after <code>run</code> has been invoked on this suite 1684 * @throws NullPointerException if <code>specText</code> or any passed test tag is <code>null</code> 1685 */ 1686 private def registerTestToIgnore(specText: String, testTags: List[Tag], testFun: FixtureParam => Any) { 1687 1688 // TODO: This is how these were, but it needs attention. Mentions "it". 1689 registerIgnoredTest(specText, testFun, "ignoreCannotAppearInsideAnIt", "FixtureFlatSpec.scala", "ignore", testTags: _*) 1690 } 1691 1692 /** 1693 * A <code>Map</code> whose keys are <code>String</code> tag names to which tests in this <code>Spec</code> belong, and values 1694 * the <code>Set</code> of test names that belong to each tag. If this <code>FlatSpec</code> contains no tags, this method returns an empty <code>Map</code>. 1695 * 1696 * <p> 1697 * This trait's implementation returns tags that were passed as strings contained in <code>Tag</code> objects passed to 1698 * methods <code>test</code> and <code>ignore</code>. 1699 * </p> 1700 */ 1701 override def tags: Map[String, Set[String]] = atomic.get.tagsMap 1702 1703 /** 1704 * Run a test. This trait's implementation runs the test registered with the name specified by 1705 * <code>testName</code>. Each test's name is a concatenation of the text of all describers surrounding a test, 1706 * from outside in, and the test's spec text, with one space placed between each item. (See the documenation 1707 * for <code>testNames</code> for an example.) 1708 * 1709 * @param testName the name of one test to execute. 1710 * @param reporter the <code>Reporter</code> to which results will be reported 1711 * @param stopper the <code>Stopper</code> that will be consulted to determine whether to stop execution early. 1712 * @param configMap a <code>Map</code> of properties that can be used by this <code>Spec</code>'s executing tests. 1713 * @throws NullPointerException if any of <code>testName</code>, <code>reporter</code>, <code>stopper</code>, or <code>configMap</code> 1714 * is <code>null</code>. 1715 */ 1716 protected override def runTest(testName: String, reporter: Reporter, stopper: Stopper, configMap: Map[String, Any], tracker: Tracker) { 1717 1718 def invokeWithFixture(theTest: TestLeaf) { 1719 theTest.testFun match { 1720 case wrapper: NoArgTestWrapper[_] => 1721 withFixture(new FixturelessTestFunAndConfigMap(testName, wrapper.test, configMap)) 1722 case fun => withFixture(new TestFunAndConfigMap(testName, fun, configMap)) 1723 } 1724 } 1725 1726 runTestImpl(thisSuite, testName, reporter, stopper, configMap, tracker, true, invokeWithFixture) 1727 } 1728 1729 /** 1730 * <p> 1731 * Run zero to many of this <code>Spec</code>'s tests. 1732 * </p> 1733 * 1734 * <p> 1735 * This method takes a <code>testName</code> parameter that optionally specifies a test to invoke. 1736 * If <code>testName</code> is <code>Some</code>, this trait's implementation of this method 1737 * invokes <code>runTest</code> on this object, passing in: 1738 * </p> 1739 * 1740 * <ul> 1741 * <li><code>testName</code> - the <code>String</code> value of the <code>testName</code> <code>Option</code> passed 1742 * to this method</li> 1743 * <li><code>reporter</code> - the <code>Reporter</code> passed to this method, or one that wraps and delegates to it</li> 1744 * <li><code>stopper</code> - the <code>Stopper</code> passed to this method, or one that wraps and delegates to it</li> 1745 * <li><code>configMap</code> - the <code>configMap</code> passed to this method, or one that wraps and delegates to it</li> 1746 * </ul> 1747 * 1748 * <p> 1749 * This method takes a <code>Set</code> of tag names that should be included (<code>tagsToInclude</code>), and a <code>Set</code> 1750 * that should be excluded (<code>tagsToExclude</code>), when deciding which of this <code>Suite</code>'s tests to execute. 1751 * If <code>tagsToInclude</code> is empty, all tests will be executed 1752 * except those those belonging to tags listed in the <code>tagsToExclude</code> <code>Set</code>. If <code>tagsToInclude</code> is non-empty, only tests 1753 * belonging to tags mentioned in <code>tagsToInclude</code>, and not mentioned in <code>tagsToExclude</code> 1754 * will be executed. However, if <code>testName</code> is <code>Some</code>, <code>tagsToInclude</code> and <code>tagsToExclude</code> are essentially ignored. 1755 * Only if <code>testName</code> is <code>None</code> will <code>tagsToInclude</code> and <code>tagsToExclude</code> be consulted to 1756 * determine which of the tests named in the <code>testNames</code> <code>Set</code> should be run. For more information on trait tags, see the main documentation for this trait. 1757 * </p> 1758 * 1759 * <p> 1760 * If <code>testName</code> is <code>None</code>, this trait's implementation of this method 1761 * invokes <code>testNames</code> on this <code>Suite</code> to get a <code>Set</code> of names of tests to potentially execute. 1762 * (A <code>testNames</code> value of <code>None</code> essentially acts as a wildcard that means all tests in 1763 * this <code>Suite</code> that are selected by <code>tagsToInclude</code> and <code>tagsToExclude</code> should be executed.) 1764 * For each test in the <code>testName</code> <code>Set</code>, in the order 1765 * they appear in the iterator obtained by invoking the <code>elements</code> method on the <code>Set</code>, this trait's implementation 1766 * of this method checks whether the test should be run based on the <code>tagsToInclude</code> and <code>tagsToExclude</code> <code>Set</code>s. 1767 * If so, this implementation invokes <code>runTest</code>, passing in: 1768 * </p> 1769 * 1770 * <ul> 1771 * <li><code>testName</code> - the <code>String</code> name of the test to run (which will be one of the names in the <code>testNames</code> <code>Set</code>)</li> 1772 * <li><code>reporter</code> - the <code>Reporter</code> passed to this method, or one that wraps and delegates to it</li> 1773 * <li><code>stopper</code> - the <code>Stopper</code> passed to this method, or one that wraps and delegates to it</li> 1774 * <li><code>configMap</code> - the <code>configMap</code> passed to this method, or one that wraps and delegates to it</li> 1775 * </ul> 1776 * 1777 * @param testName an optional name of one test to execute. If <code>None</code>, all relevant tests should be executed. 1778 * I.e., <code>None</code> acts like a wildcard that means execute all relevant tests in this <code>Spec</code>. 1779 * @param reporter the <code>Reporter</code> to which results will be reported 1780 * @param stopper the <code>Stopper</code> that will be consulted to determine whether to stop execution early. 1781 * @param tagsToInclude a <code>Set</code> of <code>String</code> tag names to include in the execution of this <code>Spec</code> 1782 * @param tagsToExclude a <code>Set</code> of <code>String</code> tag names to exclude in the execution of this <code>Spec</code> 1783 * @param configMap a <code>Map</code> of key-value pairs that can be used by this <code>Spec</code>'s executing tests. 1784 * @throws NullPointerException if any of <code>testName</code>, <code>reporter</code>, <code>stopper</code>, <code>tagsToInclude</code>, 1785 * <code>tagsToExclude</code>, or <code>configMap</code> is <code>null</code>. 1786 */ 1787 protected override def runTests(testName: Option[String], reporter: Reporter, stopper: Stopper, filter: Filter, 1788 configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker) { 1789 1790 1791 runTestsImpl(thisSuite, testName, reporter, stopper, filter, configMap, distributor, tracker, info, true, runTest) 1792 } 1793 1794 /** 1795 * An immutable <code>Set</code> of test names. If this <code>FixtureFlatSpec</code> contains no tests, this method returns an 1796 * empty <code>Set</code>. 1797 * 1798 * <p> 1799 * This trait's implementation of this method will return a set that contains the names of all registered tests. The set's 1800 * iterator will return those names in the order in which the tests were registered. Each test's name is composed 1801 * of the concatenation of the text of each surrounding describer, in order from outside in, and the text of the 1802 * example itself, with all components separated by a space. 1803 * </p> 1804 */ 1805 override def testNames: Set[String] = { 1806 // I'm returning a ListSet here so that they tests will be run in registration order 1807 ListSet(atomic.get.testNamesList.toArray: _*) 1808 } 1809 1810 override def run(testName: Option[String], reporter: Reporter, stopper: Stopper, filter: Filter, 1811 configMap: Map[String, Any], distributor: Option[Distributor], tracker: Tracker) { 1812 1813 1814 runImpl(thisSuite, testName, reporter, stopper, filter, configMap, distributor, tracker, super.run) 1815 } 1816 1817 /** 1818 * Supports shared test registration in <code>FixtureFlatSpec</code>s. 1819 * 1820 * <p> 1821 * This field supports syntax such as the following: 1822 * </p> 1823 * 1824 * <pre class="stHighlight"> 1825 * it should behave like nonFullStack(stackWithOneItem) 1826 * ^ 1827 * </pre> 1828 * 1829 * <p> 1830 * For more information and examples of the use of <code>behave</code>, see the <a href="../FlatSpec.html#SharedTests">Shared tests section</a> 1831 * in the main documentation for trait <code>FlatSpec</code>. 1832 * </p> 1833 */ 1834 protected val behave = new BehaveWord 1835} 1836