├── .gitignore ├── 3.0.x ├── README.md ├── build.sbt ├── input │ └── src │ │ └── main │ │ └── scala │ │ └── test │ │ ├── RenameAssertionsForJUnitSpec.scala │ │ ├── RenameAsyncJMockCycleSpec.scala │ │ ├── RenameCheckerAssertingSpec.scala │ │ ├── RenameCheckersSpec.scala │ │ ├── RenameCheckersSpec2.scala │ │ ├── RenameCheckersSpec3.scala │ │ ├── RenameChromeSpec.scala │ │ ├── RenameDriverSpec.scala │ │ ├── RenameEasyMockSugarSpec.scala │ │ ├── RenameFirefoxSpec.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec2.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec3.scala │ │ ├── RenameHtmlUnitSpec.scala │ │ ├── RenameInternetExplorerSpec.scala │ │ ├── RenameJMockCycleFixtureSpec.scala │ │ ├── RenameJMockCycleSpec.scala │ │ ├── RenameJMockExpectationsSpec.scala │ │ ├── RenameJUnit3SuiteSpec.scala │ │ ├── RenameJUnitRunnerSpec.scala │ │ ├── RenameJUnitSuiteLikeSpec.scala │ │ ├── RenameJUnitSuiteSpec.scala │ │ ├── RenameJUnitTestFailedErrorSpec.scala │ │ ├── RenameJUnitWrapperSuiteSpec.scala │ │ ├── RenameMockitoSugarSpec.scala │ │ ├── RenamePageSpec.scala │ │ ├── RenamePropertyChecksSpec.scala │ │ ├── RenamePropertyChecksSpec2.scala │ │ ├── RenamePropertyChecksSpec3.scala │ │ ├── RenameSafariSpec.scala │ │ ├── RenameTestNGSuiteLikeSpec.scala │ │ ├── RenameTestNGSuiteSpec.scala │ │ └── RenameTestNGWrapperSuiteSpec.scala ├── output │ └── src │ │ └── main │ │ └── scala │ │ └── test │ │ ├── RenameAssertionsForJUnitSpec.scala │ │ ├── RenameAsyncJMockCycleSpec.scala │ │ ├── RenameCheckerAssertingSpec.scala │ │ ├── RenameCheckersSpec.scala │ │ ├── RenameCheckersSpec2.scala │ │ ├── RenameCheckersSpec3.scala │ │ ├── RenameChromeSpec.scala │ │ ├── RenameDriverSpec.scala │ │ ├── RenameEasyMockSugarSpec.scala │ │ ├── RenameFirefoxSpec.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec2.scala │ │ ├── RenameGeneratorDrivenPropertyChecksSpec3.scala │ │ ├── RenameHtmlUnitSpec.scala │ │ ├── RenameInternetExplorerSpec.scala │ │ ├── RenameJMockCycleFixtureSpec.scala │ │ ├── RenameJMockCycleSpec.scala │ │ ├── RenameJMockExpectationsSpec.scala │ │ ├── RenameJUnit3SuiteSpec.scala │ │ ├── RenameJUnitRunnerSpec.scala │ │ ├── RenameJUnitSuiteLikeSpec.scala │ │ ├── RenameJUnitSuiteSpec.scala │ │ ├── RenameJUnitTestFailedErrorSpec.scala │ │ ├── RenameJUnitWrapperSuiteSpec.scala │ │ ├── RenameMockitoSugarSpec.scala │ │ ├── RenamePageSpec.scala │ │ ├── RenamePropertyChecksSpec.scala │ │ ├── RenamePropertyChecksSpec2.scala │ │ ├── RenamePropertyChecksSpec3.scala │ │ ├── RenameSafariSpec.scala │ │ ├── RenameTestNGSuiteLikeSpec.scala │ │ ├── RenameTestNGSuiteSpec.scala │ │ └── RenameTestNGWrapperSuiteSpec.scala ├── project │ ├── build.properties │ └── plugins.sbt ├── rules │ └── src │ │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── scalafix.v1.Rule │ │ └── scala │ │ └── org │ │ └── scalatest │ │ └── autofix │ │ └── v3_0_x │ │ └── RenameDeprecatedPackage.scala └── tests │ └── src │ └── test │ └── scala │ └── fix │ └── RuleSuite.scala ├── 3.1.x ├── README.md ├── build.sbt ├── input │ └── src │ │ └── main │ │ └── scala │ │ └── org │ │ └── scalatest │ │ └── examples │ │ ├── asyncfeaturespec │ │ ├── ReplaceAsyncFeatureSpec.scala │ │ └── ReplaceAsyncFeatureSpec2.scala │ │ ├── asyncfeaturespeclike │ │ ├── ReplaceAsyncFeatureSpecLike.scala │ │ └── ReplaceAsyncFeatureSpecLike2.scala │ │ ├── asyncflatspec │ │ └── ReplaceAsyncFlatSpec.scala │ │ ├── asyncflatspeclike │ │ └── ReplaceAsyncFlatSpecLike.scala │ │ ├── asyncfreespec │ │ └── ReplaceAsyncFreeSpec.scala │ │ ├── asyncfreespeclike │ │ └── ReplaceAsyncFreeSpecLike.scala │ │ ├── asyncfunspec │ │ └── ReplaceAsyncFunSpec.scala │ │ ├── asyncfunspeclike │ │ └── ReplaceAsyncFunSpecLike.scala │ │ ├── asyncfunsuite │ │ └── ReplaceAsyncFunSuite.scala │ │ ├── asyncfunsuitelike │ │ └── ReplaceAsyncFunSuiteLike.scala │ │ ├── asyncwordspec │ │ └── ReplaceAsyncWordSpec.scala │ │ ├── asyncwordspeclike │ │ └── ReplaceAsyncWordSpecLike.scala │ │ ├── diagrams │ │ └── ReplaceDiagrammedAssertions.scala │ │ ├── featurespec │ │ └── ReplaceFeatureSpec.scala │ │ ├── featurespeclike │ │ └── ReplaceFeatureSpecLike.scala │ │ ├── fixtureasyncfeaturespec │ │ └── ReplaceFixtureAsyncFeatureSpec.scala │ │ ├── fixtureasyncfeaturespeclike │ │ └── ReplaceFixtureAsyncFeatureSpecLike.scala │ │ ├── fixtureasyncflatspec │ │ └── ReplaceFixtureAsyncFlatSpec.scala │ │ ├── fixtureasyncflatspeclike │ │ └── ReplaceFixtureAsyncFlatSpecLike.scala │ │ ├── fixtureasyncfreespec │ │ └── ReplaceFixtureAsyncFreeSpec.scala │ │ ├── fixtureasyncfreespeclike │ │ └── ReplaceFixtureAsyncFreeSpecLike.scala │ │ ├── fixtureasyncfunspec │ │ └── ReplaceFixtureAsyncFunSpec.scala │ │ ├── fixtureasyncfunspeclike │ │ └── ReplaceFixtureAsyncFunSpecLike.scala │ │ ├── fixtureasyncfunsuite │ │ └── ReplaceFixtureAsyncFunSuite.scala │ │ ├── fixtureasyncfunsuitelike │ │ └── ReplaceFixtureAsyncFunSuiteLike.scala │ │ ├── fixtureasynctestregistration │ │ ├── ReplaceFixtureAsyncTestRegistration.scala │ │ └── ReplaceFixtureAsyncTestRegistration2.scala │ │ ├── fixtureasynctestsuite │ │ ├── ReplaceFixtureAsyncTestSuite.scala │ │ └── ReplaceFixtureAsyncTestSuite2.scala │ │ ├── fixtureasyncwordspec │ │ └── ReplaceFixtureAsyncWordSpec.scala │ │ ├── fixtureasyncwordspeclike │ │ └── ReplaceFixtureAsyncWordSpecLike.scala │ │ ├── fixturefeaturespec │ │ └── ReplaceFixtureFeatureSpec.scala │ │ ├── fixturefeaturespeclike │ │ └── ReplaceFixtureFeatureSpecLike.scala │ │ ├── fixtureflatspec │ │ └── ReplaceFixtureFlatSpec.scala │ │ ├── fixtureflatspeclike │ │ └── ReplaceFixtureFlatSpecLike.scala │ │ ├── fixturefreespec │ │ └── ReplaceFixtureFreeSpec.scala │ │ ├── fixturefreespeclike │ │ └── ReplaceFixtureFreeSpecLike.scala │ │ ├── fixturefunspec │ │ └── ReplaceFixtureFunSpec.scala │ │ ├── fixturefunspeclike │ │ └── ReplaceFixtureFunSpecLike.scala │ │ ├── fixturefunsuite │ │ └── ReplaceFixtureFunSuite.scala │ │ ├── fixturefunsuitelike │ │ └── ReplaceFixtureFunSuiteLike.scala │ │ ├── fixturepropspec │ │ └── ReplaceFixturePropSpec.scala │ │ ├── fixturepropspeclike │ │ └── ReplaceFixturePropSpecLike.scala │ │ ├── fixturesuite │ │ ├── ReplaceFixtureSuite.scala │ │ └── ReplaceFixtureSuite2.scala │ │ ├── fixturetestregistration │ │ ├── ReplaceFixtureTestRegistration.scala │ │ └── ReplaceFixtureTestRegistration2.scala │ │ ├── fixturetestsuite │ │ ├── ReplaceFixtureTestSuite.scala │ │ └── ReplaceFixtureTestSuite2.scala │ │ ├── fixturewordspec │ │ └── ReplaceFixtureWordSpec.scala │ │ ├── fixturewordspeclike │ │ └── ReplaceFixtureWordSpecLike.scala │ │ ├── flatspec │ │ └── ReplaceFlatSpec.scala │ │ ├── flatspeclike │ │ └── ReplaceFlatSpecLike.scala │ │ ├── freespec │ │ └── ReplaceFreeSpec.scala │ │ ├── freespeclike │ │ └── ReplaceFreeSpecLike.scala │ │ ├── funspec │ │ └── ReplaceFunSpec.scala │ │ ├── funspeclike │ │ └── ReplaceFunSpecLike.scala │ │ ├── funsuite │ │ └── ReplaceFunSuite.scala │ │ ├── funsuitelike │ │ └── ReplaceFunSuiteLike.scala │ │ ├── mustmatchers │ │ └── ReplaceMustMatchers.scala │ │ ├── pathfreespec │ │ └── ReplacePathFreeSpec.scala │ │ ├── pathfreespeclike │ │ └── ReplacePathFreeSpecLike.scala │ │ ├── pathfunspec │ │ └── ReplacePathFunSpec.scala │ │ ├── pathfunspeclike │ │ └── ReplacePathFunSpecLike.scala │ │ ├── propspec │ │ └── ReplacePropSpec.scala │ │ ├── propspeclike │ │ └── ReplacePropSpecLike.scala │ │ ├── shouldmatchers │ │ └── ReplaceShouldMatchers.scala │ │ ├── wordspec │ │ └── ReplaceWordSpec.scala │ │ └── wordspeclike │ │ └── ReplaceWordSpecLike.scala ├── output │ └── src │ │ └── main │ │ └── scala │ │ ├── org │ │ └── scalatest │ │ │ └── examples │ │ │ ├── asyncfeaturespec │ │ │ ├── ReplaceAsyncFeatureSpec.scala │ │ │ └── ReplaceAsyncFeatureSpec2.scala │ │ │ ├── asyncfeaturespeclike │ │ │ ├── ReplaceAsyncFeatureSpecLike.scala │ │ │ └── ReplaceAsyncFeatureSpecLike2.scala │ │ │ ├── asyncflatspec │ │ │ └── ReplaceAsyncFlatSpec.scala │ │ │ ├── asyncflatspeclike │ │ │ └── ReplaceAsyncFlatSpecLike.scala │ │ │ ├── asyncfreespec │ │ │ └── ReplaceAsyncFreeSpec.scala │ │ │ ├── asyncfreespeclike │ │ │ └── ReplaceAsyncFreeSpecLike.scala │ │ │ ├── asyncfunspec │ │ │ └── ReplaceAsyncFunSpec.scala │ │ │ ├── asyncfunspeclike │ │ │ └── ReplaceAsyncFunSpecLike.scala │ │ │ ├── asyncfunsuite │ │ │ └── ReplaceAsyncFunSuite.scala │ │ │ ├── asyncfunsuitelike │ │ │ └── ReplaceAsyncFunSuiteLike.scala │ │ │ ├── asyncwordspec │ │ │ └── ReplaceAsyncWordSpec.scala │ │ │ ├── asyncwordspeclike │ │ │ └── ReplaceAsyncWordSpecLike.scala │ │ │ ├── diagrams │ │ │ └── ReplaceDiagrammedAssertions.scala │ │ │ ├── featurespec │ │ │ └── ReplaceFeatureSpec.scala │ │ │ ├── featurespeclike │ │ │ └── ReplaceFeatureSpecLike.scala │ │ │ ├── fixtureasyncfeaturespec │ │ │ └── ReplaceFixtureAsyncFeatureSpec.scala │ │ │ ├── fixtureasyncfeaturespeclike │ │ │ └── ReplaceFixtureAsyncFeatureSpecLike.scala │ │ │ ├── fixtureasyncflatspec │ │ │ └── ReplaceFixtureAsyncFlatSpec.scala │ │ │ ├── fixtureasyncflatspeclike │ │ │ └── ReplaceFixtureAsyncFlatSpecLike.scala │ │ │ ├── fixtureasyncfreespec │ │ │ └── ReplaceFixtureAsyncFreeSpec.scala │ │ │ ├── fixtureasyncfreespeclike │ │ │ └── ReplaceFixtureAsyncFreeSpecLike.scala │ │ │ ├── fixtureasyncfunspec │ │ │ └── ReplaceFixtureAsyncFunSpec.scala │ │ │ ├── fixtureasyncfunspeclike │ │ │ └── ReplaceFixtureAsyncFunSpecLike.scala │ │ │ ├── fixtureasyncfunsuite │ │ │ └── ReplaceFixtureAsyncFunSuite.scala │ │ │ ├── fixtureasyncfunsuitelike │ │ │ └── ReplaceFixtureAsyncFunSuiteLike.scala │ │ │ ├── fixtureasynctestregistration │ │ │ ├── ReplaceFixtureAsyncTestRegistration.scala │ │ │ └── ReplaceFixtureAsyncTestRegistration2.scala │ │ │ ├── fixtureasynctestsuite │ │ │ ├── ReplaceFixtureAsyncTestSuite.scala │ │ │ └── ReplaceFixtureAsyncTestSuite2.scala │ │ │ ├── fixtureasyncwordspec │ │ │ └── ReplaceFixtureAsyncWordSpec.scala │ │ │ ├── fixtureasyncwordspeclike │ │ │ └── ReplaceFixtureAsyncWordSpecLike.scala │ │ │ ├── fixturefeaturespec │ │ │ └── ReplaceFixtureFeatureSpec.scala │ │ │ ├── fixturefeaturespeclike │ │ │ └── ReplaceFixtureFeatureSpecLike.scala │ │ │ ├── fixtureflatspec │ │ │ └── ReplaceFixtureFlatSpec.scala │ │ │ ├── fixtureflatspeclike │ │ │ └── ReplaceFixtureFlatSpecLike.scala │ │ │ ├── fixturefreespec │ │ │ └── ReplaceFixtureFreeSpec.scala │ │ │ ├── fixturefreespeclike │ │ │ └── ReplaceFixtureFreeSpecLike.scala │ │ │ ├── fixturefunspec │ │ │ └── ReplaceFixtureFunSpec.scala │ │ │ ├── fixturefunspeclike │ │ │ └── ReplaceFixtureFunSpecLike.scala │ │ │ ├── fixturefunsuite │ │ │ └── ReplaceFixtureFunSuite.scala │ │ │ ├── fixturefunsuitelike │ │ │ └── ReplaceFixtureFunSuiteLike.scala │ │ │ ├── fixturepropspec │ │ │ └── ReplaceFixturePropSpec.scala │ │ │ ├── fixturepropspeclike │ │ │ └── ReplaceFixturePropSpecLike.scala │ │ │ ├── fixturesuite │ │ │ ├── ReplaceFixtureSuite.scala │ │ │ └── ReplaceFixtureSuite2.scala │ │ │ ├── fixturetestregistration │ │ │ ├── ReplaceFixtureTestRegistration.scala │ │ │ └── ReplaceFixtureTestRegistration2.scala │ │ │ ├── fixturetestsuite │ │ │ ├── ReplaceFixtureTestSuite.scala │ │ │ └── ReplaceFixtureTestSuite2.scala │ │ │ ├── fixturewordspec │ │ │ └── ReplaceFixtureWordSpec.scala │ │ │ ├── fixturewordspeclike │ │ │ └── ReplaceFixtureWordSpecLike.scala │ │ │ ├── flatspec │ │ │ └── ReplaceFlatSpec.scala │ │ │ ├── flatspeclike │ │ │ └── ReplaceFlatSpecLike.scala │ │ │ ├── freespec │ │ │ └── ReplaceFreeSpec.scala │ │ │ ├── freespeclike │ │ │ └── ReplaceFreeSpecLike.scala │ │ │ ├── funspec │ │ │ └── ReplaceFunSpec.scala │ │ │ ├── funspeclike │ │ │ └── ReplaceFunSpecLike.scala │ │ │ ├── funsuite │ │ │ └── ReplaceFunSuite.scala │ │ │ ├── funsuitelike │ │ │ └── ReplaceFunSuiteLike.scala │ │ │ ├── mustmatchers │ │ │ └── ReplaceMustMatchers.scala │ │ │ ├── pathfreespec │ │ │ └── ReplacePathFreeSpec.scala │ │ │ ├── pathfreespeclike │ │ │ └── ReplacePathFreeSpecLike.scala │ │ │ ├── pathfunspec │ │ │ └── ReplacePathFunSpec.scala │ │ │ ├── pathfunspeclike │ │ │ └── ReplacePathFunSpecLike.scala │ │ │ ├── propspec │ │ │ └── ReplacePropSpec.scala │ │ │ ├── propspeclike │ │ │ └── ReplacePropSpecLike.scala │ │ │ ├── shouldmatchers │ │ │ └── ReplaceShouldMatchers.scala │ │ │ ├── wordspec │ │ │ └── ReplaceWordSpec.scala │ │ │ └── wordspeclike │ │ │ └── ReplaceWordSpecLike.scala │ │ └── test │ │ ├── ReplaceFixtureAsyncFeatureSpec.scala │ │ ├── ReplaceFixtureAsyncFeatureSpecLike.scala │ │ ├── ReplaceFixtureAsyncFlatSpec.scala │ │ ├── ReplaceFixtureAsyncFlatSpecLike.scala │ │ ├── ReplaceFixtureAsyncFreeSpec.scala │ │ ├── ReplaceFixtureAsyncFreeSpecLike.scala │ │ ├── ReplaceFixtureAsyncFunSpec.scala │ │ ├── ReplaceFixtureAsyncFunSpecLike.scala │ │ ├── ReplaceFixtureAsyncFunSuite.scala │ │ ├── ReplaceFixtureAsyncFunSuiteLike.scala │ │ ├── ReplaceFixtureAsyncTestRegistration.scala │ │ ├── ReplaceFixtureAsyncTestSuite.scala │ │ ├── ReplaceFixtureAsyncWordSpec.scala │ │ ├── ReplaceFixtureAsyncWordSpecLike.scala │ │ ├── ReplaceFixtureFeatureSpec.scala │ │ ├── ReplaceFixtureFeatureSpecLike.scala │ │ ├── ReplaceFixtureFlatSpec.scala │ │ ├── ReplaceFixtureFlatSpecLike.scala │ │ ├── ReplaceFixtureFreeSpec.scala │ │ ├── ReplaceFixtureFreeSpecLike.scala │ │ ├── ReplaceFixtureFunSpec.scala │ │ ├── ReplaceFixtureFunSpecLike.scala │ │ ├── ReplaceFixtureFunSuite.scala │ │ ├── ReplaceFixtureFunSuiteLike.scala │ │ ├── ReplaceFixturePropSpec.scala │ │ ├── ReplaceFixturePropSpecLike.scala │ │ ├── ReplaceFixtureSuite.scala │ │ ├── ReplaceFixtureTestRegistration.scala │ │ ├── ReplaceFixtureTestSuite.scala │ │ ├── ReplaceFixtureWordSpec.scala │ │ └── ReplaceFixtureWordSpecLike.scala ├── project │ ├── build.properties │ └── plugins.sbt ├── rules │ └── src │ │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── services │ │ │ └── scalafix.v1.Rule │ │ └── scala │ │ └── org │ │ └── scalatest │ │ └── autofix │ │ └── v3_1_x │ │ └── RewriteDeprecatedNames.scala └── tests │ └── src │ └── test │ └── scala │ └── fix │ └── RuleSuite.scala ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | *.log 3 | target 4 | .idea/ 5 | *.swp 6 | -------------------------------------------------------------------------------- /3.0.x/README.md: -------------------------------------------------------------------------------- 1 | # Autofix for ScalaTest 3.0.x 2 | This scalafix rule will rewrite your ScalaTest code to eliminate most of the deprecation warnings 3 | introduced in ScalaTest 3.0.8. The deprecations were primarily renames of packages containing integrations with 4 | third-party libraries, such as JUnit, TestNG, Java mocking frameworks, Selenium, and ScalaCheck. The purpose 5 | of these renames in 3.0.8 is to prepare the way for modularization of these third-party integrations in 6 | ScalaTest 3.1.0. This will allow the third-party integrations to be versioned independently with ScalaTest. 7 | 8 | To use this plugin with sbt, please follow these steps ([Maven](https://github.com/evis/scalafix-maven-plugin) 9 | and [Mill](https://github.com/joan38/mill-scalafix) plugins are also available): 10 | 11 | - Add `sbt-scalafix` to your `project/plugins.sbt` (a [newer version](https://github.com/scalacenter/sbt-scalafix/releases) might be required for the latest Scala releases): 12 | 13 | ``` 14 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.18-1") 15 | ``` 16 | 17 | - If you have `-Xfatal-warnings` set, comment it out for the scalafix process, because otherwise 18 | the deprecation warnings will stop your build before autofix is given a chance to fix them. 19 | 20 | ``` 21 | // scalacOptions += "-Xfatal-warnings" 22 | ``` 23 | 24 | - Enable scalafix for the current sbt session: 25 | 26 | ``` 27 | sbt> scalafixEnable 28 | ``` 29 | 30 | - In the sbt prompt, issue the following command to have autofix applied to your main & test source files: 31 | 32 | ``` 33 | sbt> scalafixAll dependency:RenameDeprecatedPackage@org.scalatest:autofix:3.0.8-1 34 | ``` 35 | 36 | - Check the changes made with `git diff`. 37 | 38 | - If you turned `-Xfatal-warnings` off earlier, you can turn it back on now: 39 | 40 | ``` 41 | scalacOptions += "-Xfatal-warnings" 42 | ``` 43 | 44 | 45 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameAssertionsForJUnitSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.junit.AssertionsForJUnit 8 | 9 | class RenameAssertionsForJUnitSpec extends FunSuite with AssertionsForJUnit { 10 | 11 | test("testing") { 12 | val a = 1 13 | assert(a == 1) 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameAsyncJMockCycleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.jmock.AsyncJMockCycleFixture 8 | 9 | class RenameAsyncJMockCycleSpec extends fixture.AsyncFunSuite with AsyncJMockCycleFixture { 10 | 11 | test("test example") { cycle => 12 | import cycle._ 13 | trait OneFish { 14 | def eat(food: String): Unit = () 15 | } 16 | trait TwoFish { 17 | def eat(food: String): Unit = () 18 | } 19 | val oneFishMock = mock[OneFish] 20 | val twoFishMock = mock[TwoFish] 21 | 22 | expecting { e => import e.{oneOf => OneOf} 23 | 24 | OneOf (oneFishMock).eat("red fish") 25 | OneOf (twoFishMock).eat("blue fish") 26 | } 27 | 28 | whenExecuting { 29 | oneFishMock.eat("red fish") 30 | twoFishMock.eat("green fish") 31 | } 32 | 33 | succeed 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameCheckerAssertingSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.enablers.CheckerAsserting 8 | 9 | class RenameCheckerAssertingSpec extends FunSuite { 10 | 11 | class CustomCheckerAsserting extends CheckerAsserting[String] { 12 | def check(p: org.scalacheck.Prop, prms: org.scalacheck.Test.Parameters, prettifier: org.scalactic.Prettifier, pos: org.scalactic.source.Position, argNames: Option[List[String]]) = ??? 13 | } 14 | 15 | test("test concat") { 16 | val a = new CustomCheckerAsserting 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameCheckersSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.Checkers 8 | 9 | class RenameCheckersSpec extends FunSuite with Checkers { 10 | 11 | test("test concat") { 12 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameCheckersSpec2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop._ 8 | 9 | class RenameCheckersSpec2 extends FunSuite with Checkers { 10 | 11 | test("test concat") { 12 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameCheckersSpec3.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.{Checkers, PropertyChecks} 8 | 9 | class RenameCheckersSpec3 extends FunSuite with Checkers { 10 | 11 | test("test concat") { 12 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameChromeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{ WebBrowser, Chrome } 8 | 9 | class RenameChromeSpec extends FunSuite with WebBrowser with Chrome { 10 | 11 | test("test example") { 12 | go to "https://www.artima.com" 13 | succeed 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameDriverSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{WebBrowser, Driver} 8 | 9 | trait RenameDriverSpec extends FunSpecLike with concurrent.Eventually { this: WebBrowser with Driver => 10 | describe("google.com") { 11 | 12 | it("should change its title based on the term searched") { 13 | // Cancel test when cannot access google.com 14 | try goTo("http://www.google.com") catch { case e: Throwable => cancel(e) } 15 | clickOn("q") 16 | textField("q").value = "Cheese!" 17 | submit() 18 | // Google's search is rendered dynamically with JavaScript. 19 | eventually(assert(pageTitle === "Cheese! - Google Search")) 20 | close() 21 | } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameEasyMockSugarSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.easymock.EasyMockSugar 8 | 9 | class RenameEasyMockSugarSpec extends FunSuite with EasyMockSugar { 10 | 11 | test("test example") { 12 | trait OneFish { 13 | def eat(food: String): Unit = () 14 | } 15 | trait TwoFish { 16 | def eat(food: String): Unit = () 17 | } 18 | val oneFishMock = mock[OneFish] 19 | val twoFishMock = mock[TwoFish] 20 | 21 | expecting { 22 | oneFishMock.eat("red fish") 23 | twoFishMock.eat("blue fish") 24 | } 25 | 26 | // Trying the use case of passing an existing list of mocks for 27 | // the heck of it. 28 | val mocks = List(oneFishMock, twoFishMock) 29 | 30 | whenExecuting(mocks: _*) { 31 | oneFishMock.eat("red fish") 32 | twoFishMock.eat("green fish") 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameFirefoxSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{WebBrowser, Firefox} 8 | 9 | class RenameFirefoxSpec extends FunSuite with WebBrowser with Firefox { 10 | 11 | test("test example") { 12 | go to "https://www.artima.com" 13 | succeed 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.GeneratorDrivenPropertyChecks 8 | 9 | class RenameGeneratorDrivenPropertyChecksSpec extends FunSuite with GeneratorDrivenPropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop._ 8 | 9 | class RenameGeneratorDrivenPropertyChecksSpec2 extends FunSuite with GeneratorDrivenPropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec3.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.{Checkers, GeneratorDrivenPropertyChecks} 8 | 9 | class RenameGeneratorDrivenPropertyChecksSpec3 extends FunSuite with GeneratorDrivenPropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameHtmlUnitSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{WebBrowser, HtmlUnit} 8 | 9 | class RenameHtmlUnitSpec extends FunSuite with WebBrowser with HtmlUnit { 10 | 11 | test("test example") { 12 | go to "https://www.artima.com" 13 | succeed 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameInternetExplorerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{WebBrowser, InternetExplorer} 8 | 9 | class RenameInternetExplorerSpec extends FunSuite with WebBrowser with InternetExplorer { 10 | 11 | test("test example") { 12 | go to "https://www.artima.com" 13 | succeed 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJMockCycleFixtureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.jmock.JMockCycleFixture 8 | 9 | class RenameJMockCycleFixtureSpec extends fixture.FunSuite with JMockCycleFixture { 10 | 11 | test("test example") { cycle => 12 | import cycle._ 13 | trait OneFish { 14 | def eat(food: String): Unit = () 15 | } 16 | trait TwoFish { 17 | def eat(food: String): Unit = () 18 | } 19 | val oneFishMock = mock[OneFish] 20 | val twoFishMock = mock[TwoFish] 21 | 22 | expecting { e => import e.{oneOf => OneOf} 23 | 24 | OneOf (oneFishMock).eat("red fish") 25 | OneOf (twoFishMock).eat("blue fish") 26 | } 27 | 28 | whenExecuting { 29 | oneFishMock.eat("red fish") 30 | twoFishMock.eat("green fish") 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJMockCycleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.jmock.{JMockCycleFixture, JMockCycle} 8 | 9 | class RenameJMockCycleSpec extends fixture.FunSuite with JMockCycleFixture { 10 | 11 | test("test example") { cycle: JMockCycle => 12 | import cycle._ 13 | trait OneFish { 14 | def eat(food: String): Unit = () 15 | } 16 | trait TwoFish { 17 | def eat(food: String): Unit = () 18 | } 19 | val oneFishMock = mock[OneFish] 20 | val twoFishMock = mock[TwoFish] 21 | 22 | expecting { e => import e.{oneOf => OneOf} 23 | 24 | OneOf (oneFishMock).eat("red fish") 25 | OneOf (twoFishMock).eat("blue fish") 26 | } 27 | 28 | whenExecuting { 29 | oneFishMock.eat("red fish") 30 | twoFishMock.eat("green fish") 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJMockExpectationsSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.jmock.{JMockExpectations, JMockCycleFixture} 8 | 9 | class RenameJMockExpectationsSpec extends fixture.FunSuite with JMockCycleFixture { 10 | 11 | test("test example") { cycle => 12 | import cycle._ 13 | trait OneFish { 14 | def eat(food: String): Unit = () 15 | } 16 | trait TwoFish { 17 | def eat(food: String): Unit = () 18 | } 19 | val oneFishMock = mock[OneFish] 20 | val twoFishMock = mock[TwoFish] 21 | 22 | expecting { e => import e.{oneOf => OneOf} 23 | 24 | (new JMockExpectations).oneOf (oneFishMock).eat("red fish") 25 | (new JMockExpectations).oneOf (twoFishMock).eat("blue fish") 26 | } 27 | 28 | whenExecuting { 29 | oneFishMock.eat("red fish") 30 | twoFishMock.eat("green fish") 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnit3SuiteSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.junit.JUnit3Suite 8 | 9 | class RenameJUnit3SuiteSpec extends JUnit3Suite { 10 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnitRunnerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | 8 | class RenameJUnitRunnerSpec extends FunSuite { 9 | 10 | test("testing") { 11 | val suite = new FunSuite 12 | val runner = new org.scalatest.junit.JUnitRunner(suite.getClass) 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnitSuiteLikeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.junit.JUnitSuiteLike 8 | 9 | class RenameJUnitSuiteLikeSpec extends JUnitSuiteLike { 10 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnitSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.junit.JUnitSuite 8 | 9 | class RenameJUnitSuiteSpec extends JUnitSuite { 10 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnitTestFailedErrorSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | 8 | class RenameJUnitTestFailedErrorSpec extends FunSuite { 9 | 10 | test("testing") { 11 | val a = 1 12 | if (a == 1) 13 | succeed 14 | else 15 | throw new org.scalatest.junit.JUnitTestFailedError( 16 | None, 17 | None, 18 | Right(0), 19 | None 20 | ) 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameJUnitWrapperSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | 8 | class RenameJUnitWrapperSuiteSpec extends FunSuite { 9 | 10 | test("testing") { 11 | val s = new FunSuite 12 | val juSuite = new org.scalatest.junit.JUnitWrapperSuite(s.getClass.getName, s.getClass.getClassLoader) 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameMockitoSugarSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.mockito.MockitoSugar 8 | 9 | class RenameMockitoSugarSpec extends FunSuite with MockitoSugar { 10 | 11 | test("test example") { 12 | trait OneFish { 13 | def eat(food: String): Unit = () 14 | } 15 | trait TwoFish { 16 | def eat(food: String): Unit = () 17 | } 18 | val oneFishMock = mock[OneFish] 19 | val twoFishMock = mock[TwoFish] 20 | 21 | succeed 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenamePageSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.Page 8 | 9 | class RenamePageSpec extends FunSuite { 10 | 11 | test("test example") { 12 | class TestPage extends Page { 13 | val url = "https://www.artima.com/test.html" 14 | } 15 | succeed 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenamePropertyChecksSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.PropertyChecks 8 | 9 | class RenamePropertyChecksSpec extends FunSuite with PropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenamePropertyChecksSpec2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop._ 8 | 9 | class RenamePropertyChecksSpec2 extends FunSuite with PropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenamePropertyChecksSpec3.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.prop.{Checkers, PropertyChecks} 8 | 9 | class RenamePropertyChecksSpec3 extends FunSuite with PropertyChecks with Matchers { 10 | 11 | test("testing") { 12 | forAll { (a: String) => 13 | assert(a.length < 0) 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameSafariSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.selenium.{WebBrowser, Safari} 8 | 9 | class RenameSafariSpec extends FunSuite with WebBrowser with Safari { 10 | 11 | test("test example") { 12 | go to "https://www.artima.com" 13 | succeed 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameTestNGSuiteLikeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.testng.TestNGSuiteLike 8 | 9 | class RenameTestNGSuiteLikeSpec extends TestNGSuiteLike { 10 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameTestNGSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | import org.scalatest.testng.TestNGSuite 8 | 9 | class RenameTestNGSuiteSpec extends TestNGSuite { 10 | } -------------------------------------------------------------------------------- /3.0.x/input/src/main/scala/test/RenameTestNGWrapperSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RenameDeprecatedPackage 3 | */ 4 | package test 5 | 6 | import org.scalatest._ 7 | 8 | class RenameTestNGWrapperSuiteSpec extends FunSuite { 9 | 10 | test("testing") { 11 | val s = new FunSuite 12 | val ngSuite = new org.scalatest.testng.TestNGWrapperSuite(List("suite.xml")) 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameAssertionsForJUnitSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.junit.AssertionsForJUnit 5 | 6 | class RenameAssertionsForJUnitSpec extends FunSuite with AssertionsForJUnit { 7 | 8 | test("testing") { 9 | val a = 1 10 | assert(a == 1) 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameAsyncJMockCycleSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.jmock.AsyncJMockCycleFixture 5 | 6 | class RenameAsyncJMockCycleSpec extends fixture.AsyncFunSuite with AsyncJMockCycleFixture { 7 | 8 | test("test example") { cycle => 9 | import cycle._ 10 | trait OneFish { 11 | def eat(food: String): Unit = () 12 | } 13 | trait TwoFish { 14 | def eat(food: String): Unit = () 15 | } 16 | val oneFishMock = mock[OneFish] 17 | val twoFishMock = mock[TwoFish] 18 | 19 | expecting { e => import e.{oneOf => OneOf} 20 | 21 | OneOf (oneFishMock).eat("red fish") 22 | OneOf (twoFishMock).eat("blue fish") 23 | } 24 | 25 | whenExecuting { 26 | oneFishMock.eat("red fish") 27 | twoFishMock.eat("green fish") 28 | } 29 | 30 | succeed 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameCheckerAssertingSpec.scala: -------------------------------------------------------------------------------- 1 | 2 | package test 3 | 4 | import org.scalatest._ 5 | import org.scalatestplus.scalacheck.CheckerAsserting 6 | 7 | class RenameCheckerAssertingSpec extends FunSuite { 8 | 9 | class CustomCheckerAsserting extends CheckerAsserting[String] { 10 | def check(p: org.scalacheck.Prop, prms: org.scalacheck.Test.Parameters, prettifier: org.scalactic.Prettifier, pos: org.scalactic.source.Position, argNames: Option[List[String]]) = ??? 11 | } 12 | 13 | test("test concat") { 14 | val a = new CustomCheckerAsserting 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameCheckersSpec.scala: -------------------------------------------------------------------------------- 1 | 2 | package test 3 | 4 | import org.scalatest._ 5 | import org.scalatestplus.scalacheck.Checkers 6 | 7 | class RenameCheckersSpec extends FunSuite with Checkers { 8 | 9 | test("test concat") { 10 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameCheckersSpec2.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatest.prop._ 5 | import org.scalatestplus.scalacheck.Checkers 6 | 7 | class RenameCheckersSpec2 extends FunSuite with Checkers { 8 | 9 | test("test concat") { 10 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameCheckersSpec3.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.scalacheck.Checkers 5 | 6 | class RenameCheckersSpec3 extends FunSuite with Checkers { 7 | 8 | test("test concat") { 9 | check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameChromeSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ Chrome, WebBrowser } 5 | 6 | class RenameChromeSpec extends FunSuite with WebBrowser with Chrome { 7 | 8 | test("test example") { 9 | go to "https://www.artima.com" 10 | succeed 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameDriverSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ Driver, WebBrowser } 5 | 6 | trait RenameDriverSpec extends FunSpecLike with concurrent.Eventually { this: WebBrowser with Driver => 7 | describe("google.com") { 8 | 9 | it("should change its title based on the term searched") { 10 | // Cancel test when cannot access google.com 11 | try goTo("http://www.google.com") catch { case e: Throwable => cancel(e) } 12 | clickOn("q") 13 | textField("q").value = "Cheese!" 14 | submit() 15 | // Google's search is rendered dynamically with JavaScript. 16 | eventually(assert(pageTitle === "Cheese! - Google Search")) 17 | close() 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameEasyMockSugarSpec.scala: -------------------------------------------------------------------------------- 1 | 2 | package test 3 | 4 | import org.scalatest._ 5 | import org.scalatestplus.easymock.EasyMockSugar 6 | 7 | class RenameEasyMockSugarSpec extends FunSuite with EasyMockSugar { 8 | 9 | test("test example") { 10 | trait OneFish { 11 | def eat(food: String): Unit = () 12 | } 13 | trait TwoFish { 14 | def eat(food: String): Unit = () 15 | } 16 | val oneFishMock = mock[OneFish] 17 | val twoFishMock = mock[TwoFish] 18 | 19 | expecting { 20 | oneFishMock.eat("red fish") 21 | twoFishMock.eat("blue fish") 22 | } 23 | 24 | // Trying the use case of passing an existing list of mocks for 25 | // the heck of it. 26 | val mocks = List(oneFishMock, twoFishMock) 27 | 28 | whenExecuting(mocks: _*) { 29 | oneFishMock.eat("red fish") 30 | twoFishMock.eat("green fish") 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameFirefoxSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ Firefox, WebBrowser } 5 | 6 | class RenameFirefoxSpec extends FunSuite with WebBrowser with Firefox { 7 | 8 | test("test example") { 9 | go to "https://www.artima.com" 10 | succeed 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec.scala: -------------------------------------------------------------------------------- 1 | 2 | package test 3 | 4 | import org.scalatest._ 5 | import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks 6 | 7 | class RenameGeneratorDrivenPropertyChecksSpec extends FunSuite with ScalaCheckDrivenPropertyChecks with Matchers { 8 | 9 | test("testing") { 10 | forAll { (a: String) => 11 | assert(a.length < 0) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec2.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatest.prop._ 5 | import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks 6 | 7 | class RenameGeneratorDrivenPropertyChecksSpec2 extends FunSuite with ScalaCheckDrivenPropertyChecks with Matchers { 8 | 9 | test("testing") { 10 | forAll { (a: String) => 11 | assert(a.length < 0) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameGeneratorDrivenPropertyChecksSpec3.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks 5 | 6 | class RenameGeneratorDrivenPropertyChecksSpec3 extends FunSuite with ScalaCheckDrivenPropertyChecks with Matchers { 7 | 8 | test("testing") { 9 | forAll { (a: String) => 10 | assert(a.length < 0) 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameHtmlUnitSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ HtmlUnit, WebBrowser } 5 | 6 | class RenameHtmlUnitSpec extends FunSuite with WebBrowser with HtmlUnit { 7 | 8 | test("test example") { 9 | go to "https://www.artima.com" 10 | succeed 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameInternetExplorerSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ InternetExplorer, WebBrowser } 5 | 6 | class RenameInternetExplorerSpec extends FunSuite with WebBrowser with InternetExplorer { 7 | 8 | test("test example") { 9 | go to "https://www.artima.com" 10 | succeed 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJMockCycleFixtureSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.jmock.JMockCycleFixture 5 | 6 | class RenameJMockCycleFixtureSpec extends fixture.FunSuite with JMockCycleFixture { 7 | 8 | test("test example") { cycle => 9 | import cycle._ 10 | trait OneFish { 11 | def eat(food: String): Unit = () 12 | } 13 | trait TwoFish { 14 | def eat(food: String): Unit = () 15 | } 16 | val oneFishMock = mock[OneFish] 17 | val twoFishMock = mock[TwoFish] 18 | 19 | expecting { e => import e.{oneOf => OneOf} 20 | 21 | OneOf (oneFishMock).eat("red fish") 22 | OneOf (twoFishMock).eat("blue fish") 23 | } 24 | 25 | whenExecuting { 26 | oneFishMock.eat("red fish") 27 | twoFishMock.eat("green fish") 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJMockCycleSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.jmock.{ JMockCycle, JMockCycleFixture } 5 | 6 | class RenameJMockCycleSpec extends fixture.FunSuite with JMockCycleFixture { 7 | 8 | test("test example") { cycle: JMockCycle => 9 | import cycle._ 10 | trait OneFish { 11 | def eat(food: String): Unit = () 12 | } 13 | trait TwoFish { 14 | def eat(food: String): Unit = () 15 | } 16 | val oneFishMock = mock[OneFish] 17 | val twoFishMock = mock[TwoFish] 18 | 19 | expecting { e => import e.{oneOf => OneOf} 20 | 21 | OneOf (oneFishMock).eat("red fish") 22 | OneOf (twoFishMock).eat("blue fish") 23 | } 24 | 25 | whenExecuting { 26 | oneFishMock.eat("red fish") 27 | twoFishMock.eat("green fish") 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJMockExpectationsSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.jmock.{ JMockCycleFixture, JMockExpectations } 5 | 6 | class RenameJMockExpectationsSpec extends fixture.FunSuite with JMockCycleFixture { 7 | 8 | test("test example") { cycle => 9 | import cycle._ 10 | trait OneFish { 11 | def eat(food: String): Unit = () 12 | } 13 | trait TwoFish { 14 | def eat(food: String): Unit = () 15 | } 16 | val oneFishMock = mock[OneFish] 17 | val twoFishMock = mock[TwoFish] 18 | 19 | expecting { e => import e.{oneOf => OneOf} 20 | 21 | (new JMockExpectations).oneOf (oneFishMock).eat("red fish") 22 | (new JMockExpectations).oneOf (twoFishMock).eat("blue fish") 23 | } 24 | 25 | whenExecuting { 26 | oneFishMock.eat("red fish") 27 | twoFishMock.eat("green fish") 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnit3SuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.junit.JUnit3Suite 5 | 6 | class RenameJUnit3SuiteSpec extends JUnit3Suite { 7 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnitRunnerSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | 5 | class RenameJUnitRunnerSpec extends FunSuite { 6 | 7 | test("testing") { 8 | val suite = new FunSuite 9 | val runner = new org.scalatestplus.junit.JUnitRunner(suite.getClass) 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnitSuiteLikeSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.junit.JUnitSuiteLike 5 | 6 | class RenameJUnitSuiteLikeSpec extends JUnitSuiteLike { 7 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnitSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.junit.JUnitSuite 5 | 6 | class RenameJUnitSuiteSpec extends JUnitSuite { 7 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnitTestFailedErrorSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | 5 | class RenameJUnitTestFailedErrorSpec extends FunSuite { 6 | 7 | test("testing") { 8 | val a = 1 9 | if (a == 1) 10 | succeed 11 | else 12 | throw new org.scalatestplus.junit.JUnitTestFailedError( 13 | None, 14 | None, 15 | Right(0), 16 | None 17 | ) 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameJUnitWrapperSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | 5 | class RenameJUnitWrapperSuiteSpec extends FunSuite { 6 | 7 | test("testing") { 8 | val s = new FunSuite 9 | val juSuite = new org.scalatestplus.junit.JUnitWrapperSuite(s.getClass.getName, s.getClass.getClassLoader) 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameMockitoSugarSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.mockito.MockitoSugar 5 | 6 | class RenameMockitoSugarSpec extends FunSuite with MockitoSugar { 7 | 8 | test("test example") { 9 | trait OneFish { 10 | def eat(food: String): Unit = () 11 | } 12 | trait TwoFish { 13 | def eat(food: String): Unit = () 14 | } 15 | val oneFishMock = mock[OneFish] 16 | val twoFishMock = mock[TwoFish] 17 | 18 | succeed 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenamePageSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.Page 5 | 6 | class RenamePageSpec extends FunSuite { 7 | 8 | test("test example") { 9 | class TestPage extends Page { 10 | val url = "https://www.artima.com/test.html" 11 | } 12 | succeed 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenamePropertyChecksSpec.scala: -------------------------------------------------------------------------------- 1 | 2 | package test 3 | 4 | import org.scalatest._ 5 | import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks 6 | 7 | class RenamePropertyChecksSpec extends FunSuite with ScalaCheckPropertyChecks with Matchers { 8 | 9 | test("testing") { 10 | forAll { (a: String) => 11 | assert(a.length < 0) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenamePropertyChecksSpec2.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatest.prop._ 5 | import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks 6 | 7 | class RenamePropertyChecksSpec2 extends FunSuite with ScalaCheckPropertyChecks with Matchers { 8 | 9 | test("testing") { 10 | forAll { (a: String) => 11 | assert(a.length < 0) 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenamePropertyChecksSpec3.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks 5 | 6 | class RenamePropertyChecksSpec3 extends FunSuite with ScalaCheckPropertyChecks with Matchers { 7 | 8 | test("testing") { 9 | forAll { (a: String) => 10 | assert(a.length < 0) 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameSafariSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.selenium.{ Safari, WebBrowser } 5 | 6 | class RenameSafariSpec extends FunSuite with WebBrowser with Safari { 7 | 8 | test("test example") { 9 | go to "https://www.artima.com" 10 | succeed 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameTestNGSuiteLikeSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.testng.TestNGSuiteLike 5 | 6 | class RenameTestNGSuiteLikeSpec extends TestNGSuiteLike { 7 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameTestNGSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | import org.scalatestplus.testng.TestNGSuite 5 | 6 | class RenameTestNGSuiteSpec extends TestNGSuite { 7 | } -------------------------------------------------------------------------------- /3.0.x/output/src/main/scala/test/RenameTestNGWrapperSuiteSpec.scala: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import org.scalatest._ 4 | 5 | class RenameTestNGWrapperSuiteSpec extends FunSuite { 6 | 7 | test("testing") { 8 | val s = new FunSuite 9 | val ngSuite = new org.scalatestplus.testng.TestNGWrapperSuite(List("suite.xml")) 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /3.0.x/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.13 2 | -------------------------------------------------------------------------------- /3.0.x/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | resolvers += Resolver.sonatypeRepo("releases") 2 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.18-1") 3 | addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2") 4 | addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") 5 | -------------------------------------------------------------------------------- /3.0.x/rules/src/main/resources/META-INF/services/scalafix.v1.Rule: -------------------------------------------------------------------------------- 1 | org.scalatest.autofix.v3_0_x.RenameDeprecatedPackage -------------------------------------------------------------------------------- /3.0.x/tests/src/test/scala/fix/RuleSuite.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import scalafix.testkit.SemanticRuleSuite 4 | 5 | class RuleSuite extends SemanticRuleSuite() { 6 | runAllTests() 7 | } 8 | -------------------------------------------------------------------------------- /3.1.x/README.md: -------------------------------------------------------------------------------- 1 | # Autofix for ScalaTest 3.1.x 2 | This scalafix rule will rewrite your ScalaTest code to eliminate most of the deprecation warnings 3 | introduced in ScalaTest 3.1.0. The deprecations were primarily renames of object, classes, and traits to 4 | pave the way for the internal modularization of ScalaTest in 3.2.0. The internal modularization of ScalaTest 5 | will allow projects to depend on a chosen subset of ScalaTest in their build to more easily keep test code 6 | consistent across the project. 7 | 8 | To use this plugin with sbt, please follow these steps ([Maven](https://github.com/evis/scalafix-maven-plugin) 9 | and [Mill](https://github.com/joan38/mill-scalafix) plugins are also available): 10 | 11 | - Add `sbt-scalafix` to your `project/plugins.sbt` (a [newer version](https://github.com/scalacenter/sbt-scalafix/releases) might be required for the latest Scala releases): 12 | 13 | ``` 14 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.18-1") 15 | ``` 16 | 17 | - If you have `-Xfatal-warnings` set, comment it out for the scalafix process, because otherwise 18 | the deprecation warnings will stop your build before autofix is given a chance to fix them. 19 | 20 | ``` 21 | // scalacOptions += "-Xfatal-warnings" 22 | ``` 23 | 24 | - Enable scalafix for the current sbt session: 25 | 26 | ``` 27 | sbt> scalafixEnable 28 | ``` 29 | 30 | - In the sbt prompt, issue the following command to have autofix applied to your main & test source files: 31 | 32 | ``` 33 | sbt> scalafixAll dependency:RewriteDeprecatedNames@org.scalatest:autofix:3.1.0.1 34 | ``` 35 | 36 | - Check the changes made with `git diff`. 37 | 38 | - If you turned `-Xfatal-warnings` off earlier, you can turn it back on now: 39 | 40 | ``` 41 | scalacOptions += "-Xfatal-warnings" 42 | ``` 43 | 44 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfeaturespec/ReplaceAsyncFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfeaturespec 20 | 21 | import org.scalatest.AsyncFeatureSpec 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFeatureSpec extends AsyncFeatureSpec { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | def addNow(addends: Int*): Int = addends.sum 28 | 29 | feature("The add methods") { 30 | 31 | scenario("addSoon will eventually compute a sum of passed Ints") { 32 | val futureSum: Future[Int] = addSoon(1, 2) 33 | // You can map assertions onto a Future, then return 34 | // the resulting Future[Assertion] to ScalaTest: 35 | futureSum map { sum => assert(sum == 3) } 36 | } 37 | 38 | scenario("addNow will immediately compute a sum of passed Ints") { 39 | val sum: Int = addNow(1, 2) 40 | // You can also write synchronous tests. The body 41 | // must have result type Assertion: 42 | assert(sum == 3) 43 | } 44 | } 45 | 46 | def testScenariosFor(): Unit = { 47 | scenario("scenario 1") { 48 | succeed 49 | } 50 | 51 | scenario("scenario 2") { 52 | succeed 53 | } 54 | } 55 | 56 | scenariosFor(testScenariosFor()) 57 | } 58 | 59 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfeaturespeclike/ReplaceAsyncFeatureSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfeaturespeclike 20 | 21 | import org.scalatest.AsyncFeatureSpecLike 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFeatureSpecLike extends AsyncFeatureSpecLike { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | def addNow(addends: Int*): Int = addends.sum 28 | 29 | feature("The add methods") { 30 | 31 | scenario("addSoon will eventually compute a sum of passed Ints") { 32 | val futureSum: Future[Int] = addSoon(1, 2) 33 | // You can map assertions onto a Future, then return 34 | // the resulting Future[Assertion] to ScalaTest: 35 | futureSum map { sum => assert(sum == 3) } 36 | } 37 | 38 | scenario("addNow will immediately compute a sum of passed Ints") { 39 | val sum: Int = addNow(1, 2) 40 | // You can also write synchronous tests. The body 41 | // must have result type Assertion: 42 | assert(sum == 3) 43 | } 44 | } 45 | 46 | def testScenariosFor(): Unit = { 47 | scenario("scenario 1") { 48 | succeed 49 | } 50 | 51 | scenario("scenario 2") { 52 | succeed 53 | } 54 | } 55 | 56 | scenariosFor(testScenariosFor()) 57 | } 58 | 59 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncflatspec/ReplaceAsyncFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncflatspec 20 | 21 | import org.scalatest.AsyncFlatSpec 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFlatSpec extends AsyncFlatSpec { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | behavior of "addSoon" 29 | 30 | it should "eventually compute a sum of passed Ints" in { 31 | val futureSum: Future[Int] = addSoon(1, 2) 32 | // You can map assertions onto a Future, then return 33 | // the resulting Future[Assertion] to ScalaTest: 34 | futureSum map { sum => assert(sum == 3) } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | "addNow" should "immediately compute a sum of passed Ints" in { 40 | val sum: Int = addNow(1, 2) 41 | // You can also write synchronous tests. The body 42 | // must have result type Assertion: 43 | assert(sum == 3) 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncflatspeclike/ReplaceAsyncFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncflatspeclike 20 | 21 | import org.scalatest.AsyncFlatSpecLike 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFlatSpecLike extends AsyncFlatSpecLike { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | behavior of "addSoon" 29 | 30 | it should "eventually compute a sum of passed Ints" in { 31 | val futureSum: Future[Int] = addSoon(1, 2) 32 | // You can map assertions onto a Future, then return 33 | // the resulting Future[Assertion] to ScalaTest: 34 | futureSum map { sum => assert(sum == 3) } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | "addNow" should "immediately compute a sum of passed Ints" in { 40 | val sum: Int = addNow(1, 2) 41 | // You can also write synchronous tests. The body 42 | // must have result type Assertion: 43 | assert(sum == 3) 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfreespec/ReplaceAsyncFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfreespec 20 | 21 | import org.scalatest.AsyncFreeSpec 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFreeSpec extends AsyncFreeSpec { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | "addSoon" - { 29 | "will eventually compute a sum of passed Ints" in { 30 | val futureSum: Future[Int] = addSoon(1, 2) 31 | // You can map assertions onto a Future, then return 32 | // the resulting Future[Assertion] to ScalaTest: 33 | futureSum map { sum => assert(sum == 3) } 34 | } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | "addNow" - { 40 | "will immediately compute a sum of passed Ints" in { 41 | val sum: Int = addNow(1, 2) 42 | // You can also write synchronous tests. The body 43 | // must have result type Assertion: 44 | assert(sum == 3) 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfreespeclike/ReplaceAsyncFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfreespeclike 20 | 21 | import org.scalatest.AsyncFreeSpecLike 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFreeSpecLike extends AsyncFreeSpecLike { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | "addSoon" - { 29 | "will eventually compute a sum of passed Ints" in { 30 | val futureSum: Future[Int] = addSoon(1, 2) 31 | // You can map assertions onto a Future, then return 32 | // the resulting Future[Assertion] to ScalaTest: 33 | futureSum map { sum => assert(sum == 3) } 34 | } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | "addNow" - { 40 | "will immediately compute a sum of passed Ints" in { 41 | val sum: Int = addNow(1, 2) 42 | // You can also write synchronous tests. The body 43 | // must have result type Assertion: 44 | assert(sum == 3) 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfunspec/ReplaceAsyncFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfunspec 20 | 21 | import org.scalatest.AsyncFunSpec 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFunSpec extends AsyncFunSpec { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | describe("addSoon") { 29 | it("will eventually compute a sum of passed Ints") { 30 | val futureSum: Future[Int] = addSoon(1, 2) 31 | // You can map assertions onto a Future, then return 32 | // the resulting Future[Assertion] to ScalaTest: 33 | futureSum map { sum => assert(sum == 3) } 34 | } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | describe("addNow") { 40 | it("will immediately compute a sum of passed Ints") { 41 | val sum: Int = addNow(1, 2) 42 | // You can also write synchronous tests. The body 43 | // must have result type Assertion: 44 | assert(sum == 3) 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfunspeclike/ReplaceAsyncFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfunspeclike 20 | 21 | import org.scalatest.AsyncFunSpecLike 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFunSpecLike extends AsyncFunSpecLike { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | describe("addSoon") { 29 | it("will eventually compute a sum of passed Ints") { 30 | val futureSum: Future[Int] = addSoon(1, 2) 31 | // You can map assertions onto a Future, then return 32 | // the resulting Future[Assertion] to ScalaTest: 33 | futureSum map { sum => assert(sum == 3) } 34 | } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | describe("addNow") { 40 | it("will immediately compute a sum of passed Ints") { 41 | val sum: Int = addNow(1, 2) 42 | // You can also write synchronous tests. The body 43 | // must have result type Assertion: 44 | assert(sum == 3) 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfunsuite/ReplaceAsyncFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfunsuite 20 | 21 | import org.scalatest.AsyncFunSuite 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFunSuite extends AsyncFunSuite { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | test("addSoon will eventually compute a sum of passed Ints") { 29 | val futureSum: Future[Int] = addSoon(1, 2) 30 | // You can map assertions onto a Future, then return 31 | // the resulting Future[Assertion] to ScalaTest: 32 | futureSum map { sum => assert(sum == 3) } 33 | } 34 | 35 | def addNow(addends: Int*): Int = addends.sum 36 | 37 | test("addNow will immediately compute a sum of passed Ints") { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncfunsuitelike/ReplaceAsyncFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncfunsuitelike 20 | 21 | import org.scalatest.AsyncFunSuiteLike 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncFunSuiteLike extends AsyncFunSuiteLike { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | test("addSoon will eventually compute a sum of passed Ints") { 29 | val futureSum: Future[Int] = addSoon(1, 2) 30 | // You can map assertions onto a Future, then return 31 | // the resulting Future[Assertion] to ScalaTest: 32 | futureSum map { sum => assert(sum == 3) } 33 | } 34 | 35 | def addNow(addends: Int*): Int = addends.sum 36 | 37 | test("addNow will immediately compute a sum of passed Ints") { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncwordspec/ReplaceAsyncWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2015 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.asyncwordspec 20 | 21 | import org.scalatest.AsyncWordSpec 22 | import scala.concurrent.Future 23 | 24 | class ReplaceAsyncWordSpec extends AsyncWordSpec { 25 | 26 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 27 | 28 | "addSoon" should { 29 | "eventually compute a sum of passed Ints" in { 30 | val futureSum: Future[Int] = addSoon(1, 2) 31 | // You can map assertions onto a Future, then return 32 | // the resulting Future[Assertion] to ScalaTest: 33 | futureSum map { sum => assert(sum == 3) } 34 | } 35 | } 36 | 37 | def addNow(addends: Int*): Int = addends.sum 38 | 39 | "addNow" should { 40 | "immediately compute a sum of passed Ints" in { 41 | val sum: Int = addNow(1, 2) 42 | // You can also write synchronous tests. The body 43 | // must have result type Assertion: 44 | assert(sum == 3) 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/asyncwordspeclike/ReplaceAsyncWordSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/diagrams/ReplaceDiagrammedAssertions.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.diagrams 20 | 21 | import org.scalatest.FunSuite 22 | import org.scalatest.DiagrammedAssertions 23 | 24 | class ReplaceDiagrammedAssertions extends FunSuite with DiagrammedAssertions { 25 | 26 | test("An empty Set should have size 0") { 27 | assert(Set.empty.size === 0) 28 | } 29 | 30 | test("Invoking head on an empty Set should produce NoSuchElementException") { 31 | assertThrows[NoSuchElementException] { 32 | Set.empty.head 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/featurespec/ReplaceFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.featurespec 20 | 21 | import org.scalatest._ 22 | 23 | class TVSet { 24 | private var on: Boolean = false 25 | def isOn: Boolean = on 26 | def pressPowerButton() { 27 | on = !on 28 | } 29 | } 30 | 31 | class ReplaceFeatureSpec extends FeatureSpec with GivenWhenThen { 32 | 33 | info("As a TV set owner") 34 | info("I want to be able to turn the TV on and off") 35 | info("So I can watch TV when I want") 36 | info("And save energy when I'm not watching TV") 37 | 38 | feature("TV power button") { 39 | scenario("User presses power button when TV is off") { 40 | 41 | Given("a TV that is switched off") 42 | val tv = new TVSet 43 | assert(!tv.isOn) 44 | 45 | When("the power button is pressed") 46 | tv.pressPowerButton() 47 | 48 | Then("the TV should switch on") 49 | assert(tv.isOn) 50 | } 51 | 52 | scenario("User presses power button when TV is on") { 53 | 54 | Given("a TV that is switched on") 55 | val tv = new TVSet 56 | tv.pressPowerButton() 57 | assert(tv.isOn) 58 | 59 | When("the power button is pressed") 60 | tv.pressPowerButton() 61 | 62 | Then("the TV should switch off") 63 | assert(!tv.isOn) 64 | } 65 | } 66 | 67 | def testScenariosFor(): Unit = { 68 | scenario("scenario 1") { 69 | succeed 70 | } 71 | 72 | scenario("scenario 2") { 73 | succeed 74 | } 75 | } 76 | 77 | scenariosFor(testScenariosFor()) 78 | } 79 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/featurespeclike/ReplaceFeatureSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.featurespeclike 20 | 21 | import org.scalatest._ 22 | 23 | class TVSet { 24 | private var on: Boolean = false 25 | def isOn: Boolean = on 26 | def pressPowerButton() { 27 | on = !on 28 | } 29 | } 30 | 31 | class ReplaceFeatureSpecLike extends FeatureSpecLike with GivenWhenThen { 32 | 33 | info("As a TV set owner") 34 | info("I want to be able to turn the TV on and off") 35 | info("So I can watch TV when I want") 36 | info("And save energy when I'm not watching TV") 37 | 38 | feature("TV power button") { 39 | scenario("User presses power button when TV is off") { 40 | 41 | Given("a TV that is switched off") 42 | val tv = new TVSet 43 | assert(!tv.isOn) 44 | 45 | When("the power button is pressed") 46 | tv.pressPowerButton() 47 | 48 | Then("the TV should switch on") 49 | assert(tv.isOn) 50 | } 51 | 52 | scenario("User presses power button when TV is on") { 53 | 54 | Given("a TV that is switched on") 55 | val tv = new TVSet 56 | tv.pressPowerButton() 57 | assert(tv.isOn) 58 | 59 | When("the power button is pressed") 60 | tv.pressPowerButton() 61 | 62 | Then("the TV should switch off") 63 | assert(!tv.isOn) 64 | } 65 | } 66 | 67 | def testScenariosFor(): Unit = { 68 | scenario("scenario 1") { 69 | succeed 70 | } 71 | 72 | scenario("scenario 2") { 73 | succeed 74 | } 75 | } 76 | 77 | scenariosFor(testScenariosFor()) 78 | } 79 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureasynctestregistration/ReplaceFixtureAsyncTestRegistration.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestregistration 20 | 21 | import org.scalatest.fixture 22 | import scala.concurrent.Future 23 | import org.scalatest.Assertions.succeed 24 | 25 | trait ReplaceFixtureAsyncTestRegistration { 26 | def example(tr: fixture.AsyncTestRegistration { type FixtureParam = String }): Unit = { 27 | tr.registerAsyncTest("test name")((s: String) => Future.successful(succeed)) 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureasynctestregistration/ReplaceFixtureAsyncTestRegistration2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestregistration 20 | 21 | import org.scalatest.fixture.AsyncTestRegistration 22 | import scala.concurrent.Future 23 | import org.scalatest.Assertions.succeed 24 | 25 | trait ReplaceFixtureAsyncTestRegistration2 { 26 | def example(tr: AsyncTestRegistration { type FixtureParam = String}): Unit = { 27 | tr.registerAsyncTest("test name")((s: String) => Future.successful(succeed)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureasynctestsuite/ReplaceFixtureAsyncTestSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixtureasynctestsuite 20 | 21 | import org.scalatest.fixture 22 | import org.scalatest.FutureOutcome 23 | 24 | trait ReplaceFixtureAsyncTestSuite extends fixture.AsyncTestSuite { 25 | type FixtureParam = String 26 | def withFixture(test: OneArgAsyncTest): FutureOutcome = test("hello") 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureasynctestsuite/ReplaceFixtureAsyncTestSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixtureasynctestsuite 20 | 21 | import org.scalatest.fixture.AsyncTestSuite 22 | import org.scalatest.FutureOutcome 23 | 24 | trait ReplaceFixtureAsyncTestSuite2 extends AsyncTestSuite { 25 | type FixtureParam = String 26 | def withFixture(test: OneArgAsyncTest): FutureOutcome = test("hello") 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefeaturespec/ReplaceFixtureFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefeaturespec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFeatureSpec extends fixture.FeatureSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is designed to be ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | feature("Simplicity") { 43 | scenario("User needs to read test code written by others") { f => 44 | f.writer.write("encourage clear code!") 45 | f.writer.flush() 46 | assert(f.file.length === 49) 47 | } 48 | 49 | scenario("User needs to understand what the tests are doing") { f => 50 | f.writer.write("be easy to reason about!") 51 | f.writer.flush() 52 | assert(f.file.length === 52) 53 | } 54 | } 55 | 56 | def testScenariosFor(): Unit = { 57 | scenario("scenario 1") { f => 58 | succeed 59 | } 60 | 61 | scenario("scenario 2") { f => 62 | succeed 63 | } 64 | } 65 | 66 | scenariosFor(testScenariosFor()) 67 | } 68 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefeaturespeclike/ReplaceFixtureFeatureSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefeaturespeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFeatureSpecLike extends fixture.FeatureSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is designed to be ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | feature("Simplicity") { 43 | scenario("User needs to read test code written by others") { f => 44 | f.writer.write("encourage clear code!") 45 | f.writer.flush() 46 | assert(f.file.length === 49) 47 | } 48 | 49 | scenario("User needs to understand what the tests are doing") { f => 50 | f.writer.write("be easy to reason about!") 51 | f.writer.flush() 52 | assert(f.file.length === 52) 53 | } 54 | } 55 | 56 | def testScenariosFor(): Unit = { 57 | scenario("scenario 1") { f => 58 | succeed 59 | } 60 | 61 | scenario("scenario 2") { f => 62 | succeed 63 | } 64 | } 65 | 66 | scenariosFor(testScenariosFor()) 67 | } 68 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureflatspec/ReplaceFixtureFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixtureflatspec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFlatSpec extends fixture.FlatSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" should "be easy" in { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | it should "be fun" in { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixtureflatspeclike/ReplaceFixtureFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixtureflatspeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFlatSpecLike extends fixture.FlatSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" should "be easy" in { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | it should "be fun" in { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefreespec/ReplaceFixtureFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefreespec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFreeSpec extends fixture.FreeSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" - { 43 | "should be easy" in { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | "should be fun" in { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefreespeclike/ReplaceFixtureFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefreespeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFreeSpecLike extends fixture.FreeSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" - { 43 | "should be easy" in { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | "should be fun" in { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefunspec/ReplaceFixtureFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefunspec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFunSpec extends fixture.FunSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | describe("Testing") { 43 | it("should be easy") { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | it("should be fun") { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefunspeclike/ReplaceFixtureFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefunspeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFunSpecLike extends fixture.FunSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | describe("Testing") { 43 | it("should be easy") { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | it("should be fun") { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefunsuite/ReplaceFixtureFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefunsuite 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFunSuite extends fixture.FunSuite { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | test("Testing should be easy") { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | test("Testing should be fun") { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturefunsuitelike/ReplaceFixtureFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturefunsuitelike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureFunSuiteLike extends fixture.FunSuiteLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | test("Testing should be easy") { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | test("Testing should be fun") { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturepropspec/ReplaceFixturePropSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturepropspec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixturePropSpec extends fixture.PropSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | property("Testing should be easy") { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | property("Testing should be fun") { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturepropspeclike/ReplaceFixturePropSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturepropspeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixturePropSpecLike extends fixture.PropSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | property("Testing should be easy") { f => 43 | f.writer.write("easy!") 44 | f.writer.flush() 45 | assert(f.file.length === 18) 46 | } 47 | 48 | property("Testing should be fun") { f => 49 | f.writer.write("fun!") 50 | f.writer.flush() 51 | assert(f.file.length === 17) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturesuite/ReplaceFixtureSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturesuite 20 | 21 | import org.scalatest.fixture 22 | 23 | trait ReplaceFixtureSuite extends fixture.Suite { 24 | type FixtureParam = String 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturesuite/ReplaceFixtureSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturesuite 20 | 21 | import org.scalatest.fixture.Suite 22 | 23 | trait ReplaceFixtureSuite2 extends Suite { 24 | type FixtureParam = String 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturetestregistration/ReplaceFixtureTestRegistration.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestregistration 20 | 21 | import org.scalatest.fixture 22 | 23 | trait ReplaceFixtureTestRegistration { 24 | def example(tr: fixture.TestRegistration { type FixtureParam = String }): Unit = { 25 | tr.registerTest("test name")((s: String) => 42) 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturetestregistration/ReplaceFixtureTestRegistration2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestregistration 20 | 21 | import org.scalatest.fixture.TestRegistration 22 | 23 | trait ReplaceFixtureTestRegistration2 { 24 | def example(tr: TestRegistration { type FixtureParam = String}): Unit = { 25 | tr.registerTest("test name")((s: String) => 42) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturetestsuite/ReplaceFixtureTestSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestsuite 20 | 21 | import org.scalatest.fixture 22 | import org.scalatest.Outcome 23 | 24 | trait ReplaceFixtureTestSuite extends fixture.TestSuite { 25 | type FixtureParam = String 26 | def withFixture(test: OneArgTest): Outcome = test("hello") 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturetestsuite/ReplaceFixtureTestSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturetestsuite 20 | 21 | import org.scalatest.fixture.TestSuite 22 | import org.scalatest.Outcome 23 | 24 | trait ReplaceFixtureTestSuite2 extends TestSuite { 25 | type FixtureParam = String 26 | def withFixture(test: OneArgTest): Outcome = test("hello") 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturewordspec/ReplaceFixtureWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturewordspec 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureWordSpec extends fixture.WordSpec { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" should { 43 | "be easy" in { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | "be fun" in { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/fixturewordspeclike/ReplaceFixtureWordSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.fixturewordspeclike 20 | 21 | import org.scalatest.fixture 22 | import java.io._ 23 | 24 | class ReplaceFixtureWordSpecLike extends fixture.WordSpecLike { 25 | 26 | case class FixtureParam(file: File, writer: FileWriter) 27 | 28 | def withFixture(test: OneArgTest) = { 29 | 30 | // create the fixture 31 | val file = File.createTempFile("hello", "world") 32 | val writer = new FileWriter(file) 33 | val theFixture = FixtureParam(file, writer) 34 | 35 | try { 36 | writer.write("ScalaTest is ") // set up the fixture 37 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 38 | } 39 | finally writer.close() // clean up the fixture 40 | } 41 | 42 | "Testing" should { 43 | "be easy" in { f => 44 | f.writer.write("easy!") 45 | f.writer.flush() 46 | assert(f.file.length === 18) 47 | } 48 | 49 | "be fun" in { f => 50 | f.writer.write("fun!") 51 | f.writer.flush() 52 | assert(f.file.length === 17) 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/flatspec/ReplaceFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.flatspec 20 | 21 | import org.scalatest.FlatSpec 22 | 23 | class ReplaceFlatSpec extends FlatSpec { 24 | 25 | "An empty Set" should "have size 0" in { 26 | assert(Set.empty.size === 0) 27 | } 28 | 29 | it should "produce NoSuchElementException when head is invoked" in { 30 | assertThrows[NoSuchElementException] { 31 | Set.empty.head 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/flatspeclike/ReplaceFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.flatspeclike 20 | 21 | import org.scalatest.FlatSpecLike 22 | 23 | class ReplaceFlatSpecLike extends FlatSpecLike { 24 | 25 | "An empty Set" should "have size 0" in { 26 | assert(Set.empty.size === 0) 27 | } 28 | 29 | it should "produce NoSuchElementException when head is invoked" in { 30 | assertThrows[NoSuchElementException] { 31 | Set.empty.head 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/freespec/ReplaceFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.freespec 20 | 21 | import org.scalatest.FreeSpec 22 | 23 | class ReplaceFreeSpec extends FreeSpec { 24 | 25 | "A Set" - { 26 | "when empty" - { 27 | "should have size 0" in { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | "should produce NoSuchElementException when head is invoked" in { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/freespeclike/ReplaceFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.freespeclike 20 | 21 | import org.scalatest.FreeSpecLike 22 | 23 | class ReplaceFreeSpecLike extends FreeSpecLike { 24 | 25 | "A Set" - { 26 | "when empty" - { 27 | "should have size 0" in { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | "should produce NoSuchElementException when head is invoked" in { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/funspec/ReplaceFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.funspec 20 | 21 | import org.scalatest.FunSpec 22 | 23 | class ReplaceFunSpec extends FunSpec { 24 | 25 | describe("A Set") { 26 | describe("when empty") { 27 | it("should have size 0") { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | it("should produce NoSuchElementException when head is invoked") { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/funspeclike/ReplaceFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.funspeclike 20 | 21 | import org.scalatest.FunSpecLike 22 | 23 | class ReplaceFunSpecLike extends FunSpecLike { 24 | 25 | describe("A Set") { 26 | describe("when empty") { 27 | it("should have size 0") { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | it("should produce NoSuchElementException when head is invoked") { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/funsuite/ReplaceFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.funsuite 20 | 21 | import org.scalatest.FunSuite 22 | 23 | class ReplaceFunSuite extends FunSuite { 24 | 25 | test("An empty Set should have size 0") { 26 | assert(Set.empty.size === 0) 27 | } 28 | 29 | test("Invoking head on an empty Set should produce NoSuchElementException") { 30 | assertThrows[NoSuchElementException] { 31 | Set.empty.head 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/funsuitelike/ReplaceFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.funsuitelike 20 | 21 | import org.scalatest.FunSuiteLike 22 | 23 | class ReplaceFunSuiteLike extends FunSuiteLike { 24 | 25 | test("An empty Set should have size 0") { 26 | assert(Set.empty.size === 0) 27 | } 28 | 29 | test("Invoking head on an empty Set should produce NoSuchElementException") { 30 | assertThrows[NoSuchElementException] { 31 | Set.empty.head 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/mustmatchers/ReplaceMustMatchers.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.mustmatchers 20 | 21 | import org.scalatest._ 22 | 23 | class ReplaceMustMatchers extends FunSpec with MustMatchers { 24 | 25 | describe("A Set") { 26 | describe("when empty") { 27 | it("must have size 0") { 28 | Set.empty.size mustBe 0 29 | } 30 | 31 | it("must produce NoSuchElementException when head is invoked") { 32 | a [NoSuchElementException] must be thrownBy { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/pathfreespeclike/ReplacePathFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/pathfunspeclike/ReplacePathFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/propspec/ReplacePropSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.propspec 20 | 21 | import org.scalatest._ 22 | import prop._ 23 | import scala.collection.immutable._ 24 | import java.util.NoSuchElementException 25 | 26 | class ReplacePropSpec extends PropSpec with TableDrivenPropertyChecks with Matchers { 27 | 28 | val examples = 29 | Table( 30 | "set", 31 | BitSet.empty, 32 | HashSet.empty[Int], 33 | TreeSet.empty[Int] 34 | ) 35 | 36 | property("an empty Set should have size 0") { 37 | forAll(examples) { set => 38 | set.size should be (0) 39 | } 40 | } 41 | 42 | property("invoking head on an empty set should produce NoSuchElementException") { 43 | forAll(examples) { set => 44 | a [NoSuchElementException] should be thrownBy { set.head } 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/propspeclike/ReplacePropSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.propspeclike 20 | 21 | import org.scalatest._ 22 | import prop._ 23 | import scala.collection.immutable._ 24 | import java.util.NoSuchElementException 25 | 26 | class ReplacePropSpecLike extends PropSpecLike with TableDrivenPropertyChecks with Matchers { 27 | 28 | val examples = 29 | Table( 30 | "set", 31 | BitSet.empty, 32 | HashSet.empty[Int], 33 | TreeSet.empty[Int] 34 | ) 35 | 36 | property("an empty Set should have size 0") { 37 | forAll(examples) { set => 38 | set.size should be (0) 39 | } 40 | } 41 | 42 | property("invoking head on an empty set should produce NoSuchElementException") { 43 | forAll(examples) { set => 44 | a [NoSuchElementException] should be thrownBy { set.head } 45 | } 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/shouldmatchers/ReplaceShouldMatchers.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.shouldmatchers 20 | 21 | import org.scalatest._ 22 | 23 | class ReplaceShouldMatchers extends FunSpec with Matchers { 24 | 25 | describe("A Set") { 26 | describe("when empty") { 27 | it("should have size 0") { 28 | Set.empty.size shouldBe 0 29 | } 30 | 31 | it("should produce NoSuchElementException when head is invoked") { 32 | a [NoSuchElementException] should be thrownBy { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/wordspec/ReplaceWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.wordspec 20 | 21 | import org.scalatest.WordSpec 22 | 23 | class ReplaceWordSpec extends WordSpec { 24 | 25 | "A Set" when { 26 | "empty" should { 27 | "have size 0" in { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | "produce NoSuchElementException when head is invoked" in { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/input/src/main/scala/org/scalatest/examples/wordspeclike/ReplaceWordSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | rule = RewriteDeprecatedNames 3 | */ 4 | /* 5 | * Copyright 2001-2013 Artima, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | package org.scalatest.examples.wordspeclike 20 | 21 | import org.scalatest.WordSpecLike 22 | 23 | class ReplaceWordSpec extends WordSpecLike { 24 | 25 | "A Set" when { 26 | "empty" should { 27 | "have size 0" in { 28 | assert(Set.empty.size === 0) 29 | } 30 | 31 | "produce NoSuchElementException when head is invoked" in { 32 | assertThrows[NoSuchElementException] { 33 | Set.empty.head 34 | } 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfeaturespec/ReplaceAsyncFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfeaturespec 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.featurespec.AsyncFeatureSpec 20 | 21 | class ReplaceAsyncFeatureSpec extends AsyncFeatureSpec { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | def addNow(addends: Int*): Int = addends.sum 25 | 26 | Feature("The add methods") { 27 | 28 | Scenario("addSoon will eventually compute a sum of passed Ints") { 29 | val futureSum: Future[Int] = addSoon(1, 2) 30 | // You can map assertions onto a Future, then return 31 | // the resulting Future[Assertion] to ScalaTest: 32 | futureSum map { sum => assert(sum == 3) } 33 | } 34 | 35 | Scenario("addNow will immediately compute a sum of passed Ints") { 36 | val sum: Int = addNow(1, 2) 37 | // You can also write synchronous tests. The body 38 | // must have result type Assertion: 39 | assert(sum == 3) 40 | } 41 | } 42 | 43 | def testScenariosFor(): Unit = { 44 | Scenario("scenario 1") { 45 | succeed 46 | } 47 | 48 | Scenario("scenario 2") { 49 | succeed 50 | } 51 | } 52 | 53 | ScenariosFor(testScenariosFor()) 54 | } 55 | 56 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfeaturespeclike/ReplaceAsyncFeatureSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfeaturespeclike 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.featurespec.AsyncFeatureSpecLike 20 | 21 | class ReplaceAsyncFeatureSpecLike extends AsyncFeatureSpecLike { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | def addNow(addends: Int*): Int = addends.sum 25 | 26 | Feature("The add methods") { 27 | 28 | Scenario("addSoon will eventually compute a sum of passed Ints") { 29 | val futureSum: Future[Int] = addSoon(1, 2) 30 | // You can map assertions onto a Future, then return 31 | // the resulting Future[Assertion] to ScalaTest: 32 | futureSum map { sum => assert(sum == 3) } 33 | } 34 | 35 | Scenario("addNow will immediately compute a sum of passed Ints") { 36 | val sum: Int = addNow(1, 2) 37 | // You can also write synchronous tests. The body 38 | // must have result type Assertion: 39 | assert(sum == 3) 40 | } 41 | } 42 | 43 | def testScenariosFor(): Unit = { 44 | Scenario("scenario 1") { 45 | succeed 46 | } 47 | 48 | Scenario("scenario 2") { 49 | succeed 50 | } 51 | } 52 | 53 | ScenariosFor(testScenariosFor()) 54 | } 55 | 56 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncflatspec/ReplaceAsyncFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncflatspec 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.flatspec.AsyncFlatSpec 20 | 21 | class ReplaceAsyncFlatSpec extends AsyncFlatSpec { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | behavior of "addSoon" 26 | 27 | it should "eventually compute a sum of passed Ints" in { 28 | val futureSum: Future[Int] = addSoon(1, 2) 29 | // You can map assertions onto a Future, then return 30 | // the resulting Future[Assertion] to ScalaTest: 31 | futureSum map { sum => assert(sum == 3) } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | "addNow" should "immediately compute a sum of passed Ints" in { 37 | val sum: Int = addNow(1, 2) 38 | // You can also write synchronous tests. The body 39 | // must have result type Assertion: 40 | assert(sum == 3) 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncflatspeclike/ReplaceAsyncFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncflatspeclike 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.flatspec.AsyncFlatSpecLike 20 | 21 | class ReplaceAsyncFlatSpecLike extends AsyncFlatSpecLike { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | behavior of "addSoon" 26 | 27 | it should "eventually compute a sum of passed Ints" in { 28 | val futureSum: Future[Int] = addSoon(1, 2) 29 | // You can map assertions onto a Future, then return 30 | // the resulting Future[Assertion] to ScalaTest: 31 | futureSum map { sum => assert(sum == 3) } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | "addNow" should "immediately compute a sum of passed Ints" in { 37 | val sum: Int = addNow(1, 2) 38 | // You can also write synchronous tests. The body 39 | // must have result type Assertion: 40 | assert(sum == 3) 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfreespec/ReplaceAsyncFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfreespec 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.freespec.AsyncFreeSpec 20 | 21 | class ReplaceAsyncFreeSpec extends AsyncFreeSpec { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | "addSoon" - { 26 | "will eventually compute a sum of passed Ints" in { 27 | val futureSum: Future[Int] = addSoon(1, 2) 28 | // You can map assertions onto a Future, then return 29 | // the resulting Future[Assertion] to ScalaTest: 30 | futureSum map { sum => assert(sum == 3) } 31 | } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | "addNow" - { 37 | "will immediately compute a sum of passed Ints" in { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfreespeclike/ReplaceAsyncFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfreespeclike 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.freespec.AsyncFreeSpecLike 20 | 21 | class ReplaceAsyncFreeSpecLike extends AsyncFreeSpecLike { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | "addSoon" - { 26 | "will eventually compute a sum of passed Ints" in { 27 | val futureSum: Future[Int] = addSoon(1, 2) 28 | // You can map assertions onto a Future, then return 29 | // the resulting Future[Assertion] to ScalaTest: 30 | futureSum map { sum => assert(sum == 3) } 31 | } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | "addNow" - { 37 | "will immediately compute a sum of passed Ints" in { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfunspec/ReplaceAsyncFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfunspec 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.funspec.AsyncFunSpec 20 | 21 | class ReplaceAsyncFunSpec extends AsyncFunSpec { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | describe("addSoon") { 26 | it("will eventually compute a sum of passed Ints") { 27 | val futureSum: Future[Int] = addSoon(1, 2) 28 | // You can map assertions onto a Future, then return 29 | // the resulting Future[Assertion] to ScalaTest: 30 | futureSum map { sum => assert(sum == 3) } 31 | } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | describe("addNow") { 37 | it("will immediately compute a sum of passed Ints") { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfunspeclike/ReplaceAsyncFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncfunspeclike 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.funspec.AsyncFunSpecLike 20 | 21 | class ReplaceAsyncFunSpecLike extends AsyncFunSpecLike { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | describe("addSoon") { 26 | it("will eventually compute a sum of passed Ints") { 27 | val futureSum: Future[Int] = addSoon(1, 2) 28 | // You can map assertions onto a Future, then return 29 | // the resulting Future[Assertion] to ScalaTest: 30 | futureSum map { sum => assert(sum == 3) } 31 | } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | describe("addNow") { 37 | it("will immediately compute a sum of passed Ints") { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfunsuite/ReplaceAsyncFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.asyncfunsuite 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.funsuite.AsyncFunSuite 20 | 21 | class ReplaceAsyncFunSuite extends AsyncFunSuite { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | test("addSoon will eventually compute a sum of passed Ints") { 26 | val futureSum: Future[Int] = addSoon(1, 2) 27 | // You can map assertions onto a Future, then return 28 | // the resulting Future[Assertion] to ScalaTest: 29 | futureSum map { sum => assert(sum == 3) } 30 | } 31 | 32 | def addNow(addends: Int*): Int = addends.sum 33 | 34 | test("addNow will immediately compute a sum of passed Ints") { 35 | val sum: Int = addNow(1, 2) 36 | // You can also write synchronous tests. The body 37 | // must have result type Assertion: 38 | assert(sum == 3) 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncfunsuitelike/ReplaceAsyncFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.asyncfunsuitelike 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.funsuite.AsyncFunSuiteLike 20 | 21 | class ReplaceAsyncFunSuiteLike extends AsyncFunSuiteLike { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | test("addSoon will eventually compute a sum of passed Ints") { 26 | val futureSum: Future[Int] = addSoon(1, 2) 27 | // You can map assertions onto a Future, then return 28 | // the resulting Future[Assertion] to ScalaTest: 29 | futureSum map { sum => assert(sum == 3) } 30 | } 31 | 32 | def addNow(addends: Int*): Int = addends.sum 33 | 34 | test("addNow will immediately compute a sum of passed Ints") { 35 | val sum: Int = addNow(1, 2) 36 | // You can also write synchronous tests. The body 37 | // must have result type Assertion: 38 | assert(sum == 3) 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncwordspec/ReplaceAsyncWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2015 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 | */ 16 | package org.scalatest.examples.asyncwordspec 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.wordspec.AsyncWordSpec 20 | 21 | class ReplaceAsyncWordSpec extends AsyncWordSpec { 22 | 23 | def addSoon(addends: Int*): Future[Int] = Future { addends.sum } 24 | 25 | "addSoon" should { 26 | "eventually compute a sum of passed Ints" in { 27 | val futureSum: Future[Int] = addSoon(1, 2) 28 | // You can map assertions onto a Future, then return 29 | // the resulting Future[Assertion] to ScalaTest: 30 | futureSum map { sum => assert(sum == 3) } 31 | } 32 | } 33 | 34 | def addNow(addends: Int*): Int = addends.sum 35 | 36 | "addNow" should { 37 | "immediately compute a sum of passed Ints" in { 38 | val sum: Int = addNow(1, 2) 39 | // You can also write synchronous tests. The body 40 | // must have result type Assertion: 41 | assert(sum == 3) 42 | } 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/asyncwordspeclike/ReplaceAsyncWordSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/org/scalatest/examples/asyncwordspeclike/ReplaceAsyncWordSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/diagrams/ReplaceDiagrammedAssertions.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.diagrams 17 | 18 | import org.scalatest.diagrams.Diagrams 19 | import org.scalatest.funsuite.AnyFunSuite 20 | 21 | class ReplaceDiagrammedAssertions extends AnyFunSuite with Diagrams { 22 | 23 | test("An empty Set should have size 0") { 24 | assert(Set.empty.size === 0) 25 | } 26 | 27 | test("Invoking head on an empty Set should produce NoSuchElementException") { 28 | assertThrows[NoSuchElementException] { 29 | Set.empty.head 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/featurespec/ReplaceFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.featurespec 17 | 18 | import org.scalatest._ 19 | import org.scalatest.featurespec.AnyFeatureSpec 20 | 21 | class TVSet { 22 | private var on: Boolean = false 23 | def isOn: Boolean = on 24 | def pressPowerButton() { 25 | on = !on 26 | } 27 | } 28 | 29 | class ReplaceFeatureSpec extends AnyFeatureSpec with GivenWhenThen { 30 | 31 | info("As a TV set owner") 32 | info("I want to be able to turn the TV on and off") 33 | info("So I can watch TV when I want") 34 | info("And save energy when I'm not watching TV") 35 | 36 | Feature("TV power button") { 37 | Scenario("User presses power button when TV is off") { 38 | 39 | Given("a TV that is switched off") 40 | val tv = new TVSet 41 | assert(!tv.isOn) 42 | 43 | When("the power button is pressed") 44 | tv.pressPowerButton() 45 | 46 | Then("the TV should switch on") 47 | assert(tv.isOn) 48 | } 49 | 50 | Scenario("User presses power button when TV is on") { 51 | 52 | Given("a TV that is switched on") 53 | val tv = new TVSet 54 | tv.pressPowerButton() 55 | assert(tv.isOn) 56 | 57 | When("the power button is pressed") 58 | tv.pressPowerButton() 59 | 60 | Then("the TV should switch off") 61 | assert(!tv.isOn) 62 | } 63 | } 64 | 65 | def testScenariosFor(): Unit = { 66 | Scenario("scenario 1") { 67 | succeed 68 | } 69 | 70 | Scenario("scenario 2") { 71 | succeed 72 | } 73 | } 74 | 75 | ScenariosFor(testScenariosFor()) 76 | } 77 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureasynctestregistration/ReplaceFixtureAsyncTestRegistration.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestregistration 17 | 18 | import org.scalatest.fixture 19 | import scala.concurrent.Future 20 | import org.scalatest.Assertions.succeed 21 | import org.scalatest 22 | 23 | trait ReplaceFixtureAsyncTestRegistration { 24 | def example(tr: scalatest.FixtureAsyncTestRegistration { type FixtureParam = String }): Unit = { 25 | tr.registerAsyncTest("test name")((s: String) => Future.successful(succeed)) 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureasynctestregistration/ReplaceFixtureAsyncTestRegistration2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestregistration 17 | 18 | import scala.concurrent.Future 19 | import org.scalatest.Assertions.succeed 20 | import org.scalatest.FixtureAsyncTestRegistration 21 | 22 | trait ReplaceFixtureAsyncTestRegistration2 { 23 | def example(tr: FixtureAsyncTestRegistration { type FixtureParam = String}): Unit = { 24 | tr.registerAsyncTest("test name")((s: String) => Future.successful(succeed)) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureasynctestsuite/ReplaceFixtureAsyncTestSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixtureasynctestsuite 17 | 18 | import org.scalatest.fixture 19 | import org.scalatest.FutureOutcome 20 | import org.scalatest 21 | 22 | trait ReplaceFixtureAsyncTestSuite extends scalatest.FixtureAsyncTestSuite { 23 | type FixtureParam = String 24 | def withFixture(test: OneArgAsyncTest): FutureOutcome = test("hello") 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureasynctestsuite/ReplaceFixtureAsyncTestSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixtureasynctestsuite 17 | 18 | import org.scalatest.FutureOutcome 19 | import org.scalatest.FixtureAsyncTestSuite 20 | 21 | trait ReplaceFixtureAsyncTestSuite2 extends FixtureAsyncTestSuite { 22 | type FixtureParam = String 23 | def withFixture(test: OneArgAsyncTest): FutureOutcome = test("hello") 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefeaturespec/ReplaceFixtureFeatureSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefeaturespec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.featurespec 21 | 22 | class ReplaceFixtureFeatureSpec extends featurespec.FixtureAnyFeatureSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is designed to be ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | Feature("Simplicity") { 41 | Scenario("User needs to read test code written by others") { f => 42 | f.writer.write("encourage clear code!") 43 | f.writer.flush() 44 | assert(f.file.length === 49) 45 | } 46 | 47 | Scenario("User needs to understand what the tests are doing") { f => 48 | f.writer.write("be easy to reason about!") 49 | f.writer.flush() 50 | assert(f.file.length === 52) 51 | } 52 | } 53 | 54 | def testScenariosFor(): Unit = { 55 | Scenario("scenario 1") { f => 56 | succeed 57 | } 58 | 59 | Scenario("scenario 2") { f => 60 | succeed 61 | } 62 | } 63 | 64 | ScenariosFor(testScenariosFor()) 65 | } 66 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefeaturespeclike/ReplaceFixtureFeatureSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefeaturespeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.featurespec 21 | 22 | class ReplaceFixtureFeatureSpecLike extends featurespec.FixtureAnyFeatureSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is designed to be ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | Feature("Simplicity") { 41 | Scenario("User needs to read test code written by others") { f => 42 | f.writer.write("encourage clear code!") 43 | f.writer.flush() 44 | assert(f.file.length === 49) 45 | } 46 | 47 | Scenario("User needs to understand what the tests are doing") { f => 48 | f.writer.write("be easy to reason about!") 49 | f.writer.flush() 50 | assert(f.file.length === 52) 51 | } 52 | } 53 | 54 | def testScenariosFor(): Unit = { 55 | Scenario("scenario 1") { f => 56 | succeed 57 | } 58 | 59 | Scenario("scenario 2") { f => 60 | succeed 61 | } 62 | } 63 | 64 | ScenariosFor(testScenariosFor()) 65 | } 66 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureflatspec/ReplaceFixtureFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixtureflatspec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.flatspec 21 | 22 | class ReplaceFixtureFlatSpec extends flatspec.FixtureAnyFlatSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" should "be easy" in { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | it should "be fun" in { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixtureflatspeclike/ReplaceFixtureFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixtureflatspeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.flatspec 21 | 22 | class ReplaceFixtureFlatSpecLike extends flatspec.FixtureAnyFlatSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" should "be easy" in { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | it should "be fun" in { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefreespec/ReplaceFixtureFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefreespec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.freespec 21 | 22 | class ReplaceFixtureFreeSpec extends freespec.FixtureAnyFreeSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" - { 41 | "should be easy" in { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | "should be fun" in { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefreespeclike/ReplaceFixtureFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefreespeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.freespec 21 | 22 | class ReplaceFixtureFreeSpecLike extends freespec.FixtureAnyFreeSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" - { 41 | "should be easy" in { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | "should be fun" in { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefunspec/ReplaceFixtureFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefunspec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.funspec 21 | 22 | class ReplaceFixtureFunSpec extends funspec.FixtureAnyFunSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | describe("Testing") { 41 | it("should be easy") { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | it("should be fun") { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefunspeclike/ReplaceFixtureFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefunspeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.funspec 21 | 22 | class ReplaceFixtureFunSpecLike extends funspec.FixtureAnyFunSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | describe("Testing") { 41 | it("should be easy") { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | it("should be fun") { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefunsuite/ReplaceFixtureFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefunsuite 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.funsuite 21 | 22 | class ReplaceFixtureFunSuite extends funsuite.FixtureAnyFunSuite { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | test("Testing should be easy") { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | test("Testing should be fun") { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturefunsuitelike/ReplaceFixtureFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturefunsuitelike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.funsuite 21 | 22 | class ReplaceFixtureFunSuiteLike extends funsuite.FixtureAnyFunSuiteLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | test("Testing should be easy") { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | test("Testing should be fun") { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturepropspec/ReplaceFixturePropSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturepropspec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.propspec 21 | 22 | class ReplaceFixturePropSpec extends propspec.FixtureAnyPropSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | property("Testing should be easy") { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | property("Testing should be fun") { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturepropspeclike/ReplaceFixturePropSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturepropspeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.propspec 21 | 22 | class ReplaceFixturePropSpecLike extends propspec.FixtureAnyPropSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | property("Testing should be easy") { f => 41 | f.writer.write("easy!") 42 | f.writer.flush() 43 | assert(f.file.length === 18) 44 | } 45 | 46 | property("Testing should be fun") { f => 47 | f.writer.write("fun!") 48 | f.writer.flush() 49 | assert(f.file.length === 17) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturesuite/ReplaceFixtureSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturesuite 17 | 18 | import org.scalatest.fixture 19 | import org.scalatest 20 | 21 | trait ReplaceFixtureSuite extends scalatest.FixtureSuite { 22 | type FixtureParam = String 23 | } 24 | 25 | 26 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturesuite/ReplaceFixtureSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturesuite 17 | 18 | import org.scalatest.FixtureSuite 19 | 20 | trait ReplaceFixtureSuite2 extends FixtureSuite { 21 | type FixtureParam = String 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturetestregistration/ReplaceFixtureTestRegistration.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestregistration 17 | 18 | import org.scalatest.fixture 19 | import org.scalatest 20 | 21 | trait ReplaceFixtureTestRegistration { 22 | def example(tr: scalatest.FixtureTestRegistration { type FixtureParam = String }): Unit = { 23 | tr.registerTest("test name")((s: String) => 42) 24 | } 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturetestregistration/ReplaceFixtureTestRegistration2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestregistration 17 | 18 | import org.scalatest.FixtureTestRegistration 19 | 20 | trait ReplaceFixtureTestRegistration2 { 21 | def example(tr: FixtureTestRegistration { type FixtureParam = String}): Unit = { 22 | tr.registerTest("test name")((s: String) => 42) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturetestsuite/ReplaceFixtureTestSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestsuite 17 | 18 | import org.scalatest.fixture 19 | import org.scalatest.Outcome 20 | import org.scalatest 21 | 22 | trait ReplaceFixtureTestSuite extends scalatest.FixtureTestSuite { 23 | type FixtureParam = String 24 | def withFixture(test: OneArgTest): Outcome = test("hello") 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturetestsuite/ReplaceFixtureTestSuite2.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturetestsuite 17 | 18 | import org.scalatest.Outcome 19 | import org.scalatest.FixtureTestSuite 20 | 21 | trait ReplaceFixtureTestSuite2 extends FixtureTestSuite { 22 | type FixtureParam = String 23 | def withFixture(test: OneArgTest): Outcome = test("hello") 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturewordspec/ReplaceFixtureWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturewordspec 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.wordspec 21 | 22 | class ReplaceFixtureWordSpec extends wordspec.FixtureAnyWordSpec { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" should { 41 | "be easy" in { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | "be fun" in { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/fixturewordspeclike/ReplaceFixtureWordSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.fixturewordspeclike 17 | 18 | import org.scalatest.fixture 19 | import java.io._ 20 | import org.scalatest.wordspec 21 | 22 | class ReplaceFixtureWordSpecLike extends wordspec.FixtureAnyWordSpecLike { 23 | 24 | case class FixtureParam(file: File, writer: FileWriter) 25 | 26 | def withFixture(test: OneArgTest) = { 27 | 28 | // create the fixture 29 | val file = File.createTempFile("hello", "world") 30 | val writer = new FileWriter(file) 31 | val theFixture = FixtureParam(file, writer) 32 | 33 | try { 34 | writer.write("ScalaTest is ") // set up the fixture 35 | withFixture(test.toNoArgTest(theFixture)) // "loan" the fixture to the test 36 | } 37 | finally writer.close() // clean up the fixture 38 | } 39 | 40 | "Testing" should { 41 | "be easy" in { f => 42 | f.writer.write("easy!") 43 | f.writer.flush() 44 | assert(f.file.length === 18) 45 | } 46 | 47 | "be fun" in { f => 48 | f.writer.write("fun!") 49 | f.writer.flush() 50 | assert(f.file.length === 17) 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/flatspec/ReplaceFlatSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.flatspec 17 | 18 | import org.scalatest.flatspec.AnyFlatSpec 19 | 20 | class ReplaceFlatSpec extends AnyFlatSpec { 21 | 22 | "An empty Set" should "have size 0" in { 23 | assert(Set.empty.size === 0) 24 | } 25 | 26 | it should "produce NoSuchElementException when head is invoked" in { 27 | assertThrows[NoSuchElementException] { 28 | Set.empty.head 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/flatspeclike/ReplaceFlatSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.flatspeclike 17 | 18 | import org.scalatest.flatspec.AnyFlatSpecLike 19 | 20 | class ReplaceFlatSpecLike extends AnyFlatSpecLike { 21 | 22 | "An empty Set" should "have size 0" in { 23 | assert(Set.empty.size === 0) 24 | } 25 | 26 | it should "produce NoSuchElementException when head is invoked" in { 27 | assertThrows[NoSuchElementException] { 28 | Set.empty.head 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/freespec/ReplaceFreeSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.freespec 17 | 18 | import org.scalatest.freespec.AnyFreeSpec 19 | 20 | class ReplaceFreeSpec extends AnyFreeSpec { 21 | 22 | "A Set" - { 23 | "when empty" - { 24 | "should have size 0" in { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | "should produce NoSuchElementException when head is invoked" in { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/freespeclike/ReplaceFreeSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.freespeclike 17 | 18 | import org.scalatest.freespec.AnyFreeSpecLike 19 | 20 | class ReplaceFreeSpecLike extends AnyFreeSpecLike { 21 | 22 | "A Set" - { 23 | "when empty" - { 24 | "should have size 0" in { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | "should produce NoSuchElementException when head is invoked" in { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/funspec/ReplaceFunSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.funspec 17 | 18 | import org.scalatest.funspec.AnyFunSpec 19 | 20 | class ReplaceFunSpec extends AnyFunSpec { 21 | 22 | describe("A Set") { 23 | describe("when empty") { 24 | it("should have size 0") { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | it("should produce NoSuchElementException when head is invoked") { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/funspeclike/ReplaceFunSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.funspeclike 17 | 18 | import org.scalatest.funspec.AnyFunSpecLike 19 | 20 | class ReplaceFunSpecLike extends AnyFunSpecLike { 21 | 22 | describe("A Set") { 23 | describe("when empty") { 24 | it("should have size 0") { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | it("should produce NoSuchElementException when head is invoked") { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/funsuite/ReplaceFunSuite.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.funsuite 17 | 18 | import org.scalatest.funsuite.AnyFunSuite 19 | 20 | class ReplaceFunSuite extends AnyFunSuite { 21 | 22 | test("An empty Set should have size 0") { 23 | assert(Set.empty.size === 0) 24 | } 25 | 26 | test("Invoking head on an empty Set should produce NoSuchElementException") { 27 | assertThrows[NoSuchElementException] { 28 | Set.empty.head 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/funsuitelike/ReplaceFunSuiteLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.funsuitelike 17 | 18 | import org.scalatest.funsuite.AnyFunSuiteLike 19 | 20 | class ReplaceFunSuiteLike extends AnyFunSuiteLike { 21 | 22 | test("An empty Set should have size 0") { 23 | assert(Set.empty.size === 0) 24 | } 25 | 26 | test("Invoking head on an empty Set should produce NoSuchElementException") { 27 | assertThrows[NoSuchElementException] { 28 | Set.empty.head 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/mustmatchers/ReplaceMustMatchers.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.mustmatchers 17 | 18 | import org.scalatest._ 19 | import org.scalatest.funspec.AnyFunSpec 20 | import org.scalatest.matchers.must.Matchers 21 | 22 | class ReplaceMustMatchers extends AnyFunSpec with Matchers { 23 | 24 | describe("A Set") { 25 | describe("when empty") { 26 | it("must have size 0") { 27 | Set.empty.size mustBe 0 28 | } 29 | 30 | it("must produce NoSuchElementException when head is invoked") { 31 | a [NoSuchElementException] must be thrownBy { 32 | Set.empty.head 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/pathfreespeclike/ReplacePathFreeSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/org/scalatest/examples/pathfreespeclike/ReplacePathFreeSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/pathfunspeclike/ReplacePathFunSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/org/scalatest/examples/pathfunspeclike/ReplacePathFunSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/propspec/ReplacePropSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.propspec 17 | 18 | import org.scalatest._ 19 | import prop._ 20 | import scala.collection.immutable._ 21 | import java.util.NoSuchElementException 22 | import org.scalatest.matchers.should.Matchers 23 | import org.scalatest.propspec.AnyPropSpec 24 | 25 | class ReplacePropSpec extends AnyPropSpec with TableDrivenPropertyChecks with Matchers { 26 | 27 | val examples = 28 | Table( 29 | "set", 30 | BitSet.empty, 31 | HashSet.empty[Int], 32 | TreeSet.empty[Int] 33 | ) 34 | 35 | property("an empty Set should have size 0") { 36 | forAll(examples) { set => 37 | set.size should be (0) 38 | } 39 | } 40 | 41 | property("invoking head on an empty set should produce NoSuchElementException") { 42 | forAll(examples) { set => 43 | a [NoSuchElementException] should be thrownBy { set.head } 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/propspeclike/ReplacePropSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.propspeclike 17 | 18 | import org.scalatest._ 19 | import prop._ 20 | import scala.collection.immutable._ 21 | import java.util.NoSuchElementException 22 | import org.scalatest.matchers.should.Matchers 23 | import org.scalatest.propspec.AnyPropSpecLike 24 | 25 | class ReplacePropSpecLike extends AnyPropSpecLike with TableDrivenPropertyChecks with Matchers { 26 | 27 | val examples = 28 | Table( 29 | "set", 30 | BitSet.empty, 31 | HashSet.empty[Int], 32 | TreeSet.empty[Int] 33 | ) 34 | 35 | property("an empty Set should have size 0") { 36 | forAll(examples) { set => 37 | set.size should be (0) 38 | } 39 | } 40 | 41 | property("invoking head on an empty set should produce NoSuchElementException") { 42 | forAll(examples) { set => 43 | a [NoSuchElementException] should be thrownBy { set.head } 44 | } 45 | } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/shouldmatchers/ReplaceShouldMatchers.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.shouldmatchers 17 | 18 | import org.scalatest._ 19 | import org.scalatest.funspec.AnyFunSpec 20 | import org.scalatest.matchers.should.Matchers 21 | 22 | class ReplaceShouldMatchers extends AnyFunSpec with Matchers { 23 | 24 | describe("A Set") { 25 | describe("when empty") { 26 | it("should have size 0") { 27 | Set.empty.size shouldBe 0 28 | } 29 | 30 | it("should produce NoSuchElementException when head is invoked") { 31 | a [NoSuchElementException] should be thrownBy { 32 | Set.empty.head 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/wordspec/ReplaceWordSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.wordspec 17 | 18 | import org.scalatest.wordspec.AnyWordSpec 19 | 20 | class ReplaceWordSpec extends AnyWordSpec { 21 | 22 | "A Set" when { 23 | "empty" should { 24 | "have size 0" in { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | "produce NoSuchElementException when head is invoked" in { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/org/scalatest/examples/wordspeclike/ReplaceWordSpecLike.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2001-2013 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 | */ 16 | package org.scalatest.examples.wordspeclike 17 | 18 | import org.scalatest.wordspec.AnyWordSpecLike 19 | 20 | class ReplaceWordSpec extends AnyWordSpecLike { 21 | 22 | "A Set" when { 23 | "empty" should { 24 | "have size 0" in { 25 | assert(Set.empty.size === 0) 26 | } 27 | 28 | "produce NoSuchElementException when head is invoked" in { 29 | assertThrows[NoSuchElementException] { 30 | Set.empty.head 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFeatureSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFeatureSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFeatureSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFeatureSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFlatSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFlatSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFlatSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFlatSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFreeSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFreeSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFreeSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFreeSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSuite.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSuite.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSuiteLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncFunSuiteLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncTestRegistration.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncTestRegistration.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncTestSuite.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncTestSuite.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncWordSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncWordSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncWordSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureAsyncWordSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFeatureSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFeatureSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFeatureSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFeatureSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFlatSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFlatSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFlatSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFlatSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFreeSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFreeSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFreeSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFreeSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFunSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFunSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFunSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFunSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFunSuite.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFunSuite.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureFunSuiteLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureFunSuiteLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixturePropSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixturePropSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixturePropSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixturePropSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureSuite.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureSuite.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureTestRegistration.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureTestRegistration.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureTestSuite.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureTestSuite.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureWordSpec.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureWordSpec.scala -------------------------------------------------------------------------------- /3.1.x/output/src/main/scala/test/ReplaceFixtureWordSpecLike.scala: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scalatest/autofix/d1fad4842e65c9c54e710d8e9b9de39dfe4527ae/3.1.x/output/src/main/scala/test/ReplaceFixtureWordSpecLike.scala -------------------------------------------------------------------------------- /3.1.x/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.3.13 2 | -------------------------------------------------------------------------------- /3.1.x/project/plugins.sbt: -------------------------------------------------------------------------------- 1 | resolvers += Resolver.sonatypeRepo("releases") 2 | addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.18-1") 3 | addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2") 4 | addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") 5 | -------------------------------------------------------------------------------- /3.1.x/rules/src/main/resources/META-INF/services/scalafix.v1.Rule: -------------------------------------------------------------------------------- 1 | org.scalatest.autofix.v3_1_x.RewriteDeprecatedNames 2 | -------------------------------------------------------------------------------- /3.1.x/tests/src/test/scala/fix/RuleSuite.scala: -------------------------------------------------------------------------------- 1 | package fix 2 | 3 | import scalafix.testkit.SemanticRuleSuite 4 | 5 | class RuleSuite extends SemanticRuleSuite() { 6 | runAllTests() 7 | } 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ScalaTest Autofix 2 | Auto-fixing error due to version upgrade, good practice etc. 3 | 4 | This project is based on Scalafix: 5 | 6 | https://github.com/scalacenter/scalafix --------------------------------------------------------------------------------