Skip to content

Commit d19179a

Browse files
committed
Merge remote-tracking branch 'origin/feature-deprecate-stylename-and-chosenstyles' into feature-deprecate-test-registration-traits
2 parents a691c24 + d5d8cda commit d19179a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+334
-458
lines changed

scalatest-test/src/test/scala/org/scalatest/FunSuiteSpec.scala

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,35 +1250,6 @@ class FunSuiteSpec extends FunSpec {
12501250
}
12511251
}
12521252

1253-
it("should throw a NotAllowedException if chosenStyles is defined and does not include FunSuite") {
1254-
1255-
class SimpleSuite extends FunSuite {
1256-
test("one") {/* ASSERTION_SUCCEED */}
1257-
test("two") {/* ASSERTION_SUCCEED */}
1258-
test("three") {/* ASSERTION_SUCCEED */}
1259-
}
1260-
1261-
val simpleSuite = new SimpleSuite()
1262-
simpleSuite.run(None, Args(SilentReporter))
1263-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funsuite.AnyFunSuite")), None, new Tracker, Set.empty))
1264-
val caught =
1265-
intercept[NotAllowedException] {
1266-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funspec.AnyFunSpec")), None, new Tracker, Set.empty))
1267-
}
1268-
import OptionValues._
1269-
assert(caught.message.value === Resources.notTheChosenStyle("org.scalatest.funsuite.AnyFunSuite", "org.scalatest.funspec.AnyFunSpec"))
1270-
val caught2 =
1271-
intercept[NotAllowedException] {
1272-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funspec.AnyFunSpec", "org.scalatest.freespec.AnyFreeSpec")), None, new Tracker, Set.empty))
1273-
}
1274-
assert(caught2.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.funsuite.AnyFunSuite", Suite.makeListForHumans(Vector("org.scalatest.funspec.AnyFunSpec", "org.scalatest.freespec.AnyFreeSpec"))))
1275-
val caught3 =
1276-
intercept[NotAllowedException] {
1277-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funspec.AnyFunSpec", "org.scalatest.freespec.AnyFreeSpec", "org.scalatest.flatspec.AnyFlatSpec")), None, new Tracker, Set.empty))
1278-
}
1279-
assert(caught3.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.funsuite.AnyFunSuite", Suite.makeListForHumans(Vector("org.scalatest.funspec.AnyFunSpec", "org.scalatest.freespec.AnyFreeSpec", "org.scalatest.flatspec.AnyFlatSpec"))))
1280-
}
1281-
12821253
describe("registerTest and registerIgnoredTest method") {
12831254

12841255
it("should allow test registration and ignored test registration") {

scalatest-test/src/test/scala/org/scalatest/RefSpecSpec.scala

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2367,35 +2367,6 @@ class RefSpecSpec extends FunSpec with PrivateMethodTester {
23672367
}
23682368
}
23692369

2370-
it("should run only chosen styles, if specified, and throw an exception from run if a non-chosen style is attempted to be run") {
2371-
2372-
class SimpleSpec extends RefSpec {
2373-
def `test method 1`: Unit = {}
2374-
def `test method 2`: Unit = {}
2375-
def `test method 3`: Unit = {}
2376-
}
2377-
2378-
val simpleSpec = new SimpleSpec()
2379-
simpleSpec.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap.empty, None, new Tracker, Set.empty))
2380-
simpleSpec.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.refspec.RefSpec")), None, new Tracker, Set.empty))
2381-
val caught =
2382-
intercept[NotAllowedException] {
2383-
simpleSpec.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec")), None, new Tracker, Set.empty))
2384-
}
2385-
import OptionValues._
2386-
assert(caught.message.value === Resources.notTheChosenStyle("org.scalatest.refspec.RefSpec", "org.scalatest.FunSpec"))
2387-
val caught2 =
2388-
intercept[NotAllowedException] {
2389-
simpleSpec.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec", "org.scalatest.FreeSpec")), None, new Tracker, Set.empty))
2390-
}
2391-
assert(caught2.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.refspec.RefSpec", Suite.makeListForHumans(Vector("org.scalatest.FunSpec", "org.scalatest.FreeSpec"))))
2392-
val caught3 =
2393-
intercept[NotAllowedException] {
2394-
simpleSpec.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec", "org.scalatest.FreeSpec", "org.scalatest.FlatSpec")), None, new Tracker, Set.empty))
2395-
}
2396-
assert(caught3.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.refspec.RefSpec", Suite.makeListForHumans(Vector("org.scalatest.FunSpec", "org.scalatest.FreeSpec", "org.scalatest.FlatSpec"))))
2397-
}
2398-
23992370
describe("when a test fails") {
24002371
it("should send proper stack depth information") {
24012372
class TestSpec extends RefSpec {
@@ -2627,4 +2598,4 @@ class NormalRefSpec extends RefSpec
26272598
@WrapWith(classOf[ConfigMapWrapperSuite])
26282599
class WrappedRefSpec(configMap: Map[_, _]) extends RefSpec
26292600
@DoNotDiscover
2630-
class NotAccessibleRefSpec(name: String) extends RefSpec
2601+
class NotAccessibleRefSpec(name: String) extends RefSpec

scalatest-test/src/test/scala/org/scalatest/SuiteSuite.scala

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -257,47 +257,6 @@ class SuiteSuite extends RefSpec with SeveredStackTraces {
257257
assert(new NotAccessibleSuite("test").rerunner === None)
258258
}
259259

260-
def `test check chosenStyles` = {
261-
class SimpleSpec extends RefSpec {
262-
def `test method 1`: Unit = {}
263-
def `test method 2`: Unit = {}
264-
def `test method 3`: Unit = {}
265-
}
266-
267-
val simpleSuite = new SimpleSpec()
268-
simpleSuite.run(None, Args(SilentReporter))
269-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.refspec.RefSpec")), None, new Tracker, Set.empty))
270-
val caught =
271-
intercept[NotAllowedException] {
272-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec")), None, new Tracker, Set.empty))
273-
}
274-
import OptionValues._
275-
assert(caught.message.value === Resources.notTheChosenStyle("org.scalatest.refspec.RefSpec", "org.scalatest.FunSpec"))
276-
val caught2 =
277-
intercept[NotAllowedException] {
278-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec", "org.scalatest.FreeSpec")), None, new Tracker, Set.empty))
279-
}
280-
assert(caught2.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.refspec.RefSpec", Suite.makeListForHumans(Vector("org.scalatest.FunSpec", "org.scalatest.FreeSpec"))))
281-
val caught3 =
282-
intercept[NotAllowedException] {
283-
simpleSuite.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.FunSpec", "org.scalatest.FreeSpec", "org.scalatest.FlatSpec")), None, new Tracker, Set.empty))
284-
}
285-
assert(caught3.message.value === Resources.notOneOfTheChosenStyles("org.scalatest.refspec.RefSpec", Suite.makeListForHumans(Vector("org.scalatest.FunSpec", "org.scalatest.FreeSpec", "org.scalatest.FlatSpec"))))
286-
}
287-
288-
def `test make list for humans` = {
289-
assert(Suite.makeListForHumans(Vector.empty) === "<empty list>")
290-
assert(Suite.makeListForHumans(Vector("")) === "\"\"")
291-
assert(Suite.makeListForHumans(Vector(" ")) === "\" \"")
292-
assert(Suite.makeListForHumans(Vector("FunSuite FunSpec")) === "\"FunSuite FunSpec\"")
293-
assert(Suite.makeListForHumans(Vector("hi")) === "hi")
294-
assert(Suite.makeListForHumans(Vector("ho")) === "ho")
295-
assert(Suite.makeListForHumans(Vector("hi", "ho")) === Resources.leftAndRight("hi", "ho"))
296-
assert(Suite.makeListForHumans(Vector("fee", "fie", "foe", "fum")) === "fee, fie, " + Resources.leftCommaAndRight("foe", "fum"))
297-
assert(Suite.makeListForHumans(Vector("A", "stitch", "in", "time", "saves", "nine")) === "A, stitch, in, time, " + Resources.leftCommaAndRight("saves", "nine"))
298-
assert(Suite.makeListForHumans(Vector("fee ", "fie", " foe", "fum")) === "\"fee \", fie, " + Resources.leftCommaAndRight("\" foe\"", "fum"))
299-
}
300-
301260
def `test stack depth` = {
302261
class TestSpec extends RefSpec {
303262
def `test failure` = {

scalatest-test/src/test/scala/org/scalatest/SuitesSpec.scala

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,6 @@ class SuitesSpec extends FunSpec {
4242
new Suites(aNull: _*)
4343
}
4444
}
45-
it("should not care about chosenStyles if it contains no tests directly and only contains nested suites with no tests") {
46-
val f = new Suites(a, b, c, d, e)
47-
f.run(None, Args(SilentReporter))
48-
f.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("FunSuite")), None, new Tracker, Set.empty))
49-
// TODO: Is this test really testing anything?
50-
}
51-
52-
it("should care about chosenStyles if it contains tests directly") {
53-
54-
class SuitesWithSpecStyleTests(suitesToNest: Suite*) extends Suites(suitesToNest.toList: _*) with FunSpecLike {
55-
it("test method 1") {}
56-
it("test method 2") {}
57-
}
58-
59-
val g = new SuitesWithSpecStyleTests(a, b, c, d, e)
60-
// OK if no chosen styles specified
61-
g.run(None, Args(SilentReporter))
62-
// OK if chosen styles is Suite, because that's the style of *tests* written in this Suites
63-
g.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funspec.AnyFunSpec")), None, new Tracker, Set.empty))
64-
intercept[NotAllowedException] {
65-
// Should not allow if chosen styles is FunSuite, because Suite is the style of *tests* written in this Suites
66-
g.run(None, Args(SilentReporter, Stopper.default, Filter(), ConfigMap(CHOSEN_STYLES -> Set("org.scalatest.funsuite.AnyFunSuite")), None, new Tracker, Set.empty))
67-
}
68-
}
6945
}
7046
}
7147

scalatest-test/src/test/scala/org/scalatest/tools/FrameworkSuite.scala

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,52 +1181,6 @@ class FrameworkSuite extends FunSuite {
11811181
}
11821182
}
11831183

1184-
test("-y should do nothing when the task to execute is a chosen style", Retryable) {
1185-
val runner = framework.runner(Array("-y", "org.scalatest.funsuite.AnyFunSuite", "-C", classOf[EventRecordingReporter].getName), Array.empty, testClassLoader)
1186-
makeSureDone(runner) {
1187-
val testEventHandler = new TestEventHandler
1188-
val tasks = runner.tasks(Array(new TaskDef("org.scalatest.tools.scalasbt.SampleSuite", subclassFingerprint, false, Array(new SuiteSelector))))
1189-
val task = tasks(0)
1190-
task.execute(testEventHandler, Array(new TestLogger))
1191-
assert(testEventHandler.successEventsReceived.size === 3)
1192-
assert(runner.isInstanceOf[org.scalatest.tools.Framework#ScalaTestRunner])
1193-
val scalatestRunner = runner.asInstanceOf[org.scalatest.tools.Framework#ScalaTestRunner]
1194-
scalatestRunner.done()
1195-
scalatestRunner.dispatchReporter.reporters.find(_.isInstanceOf[EventRecordingReporter]) match {
1196-
case Some(recordingRep : EventRecordingReporter) =>
1197-
assert(recordingRep.testSucceededEventsReceived.size === 3)
1198-
assert(recordingRep.suiteCompletedEventsReceived.size === 1)
1199-
case _ => fail("Expected to find EventRecordingReporter, but not found.")
1200-
}
1201-
}
1202-
}
1203-
1204-
test("-y should get SuiteAborted event with NotAllowedException when the task to execute is not a chosen style") {
1205-
val runner = framework.runner(Array("-y", "org.scalatest.funspec.AnyFunSpec", "-C", classOf[EventRecordingReporter].getName), Array.empty, testClassLoader)
1206-
makeSureDone(runner) {
1207-
val testEventHandler = new TestEventHandler
1208-
val tasks = runner.tasks(Array(new TaskDef("org.scalatest.tools.scalasbt.SampleSuite", subclassFingerprint, false, Array(new SuiteSelector))))
1209-
val task = tasks(0)
1210-
task.execute(testEventHandler, Array(new TestLogger))
1211-
assert(testEventHandler.successEventsReceived.size === 0)
1212-
assert(runner.isInstanceOf[org.scalatest.tools.Framework#ScalaTestRunner])
1213-
val scalatestRunner = runner.asInstanceOf[org.scalatest.tools.Framework#ScalaTestRunner]
1214-
scalatestRunner.done()
1215-
scalatestRunner.dispatchReporter.reporters.find(_.isInstanceOf[EventRecordingReporter]) match {
1216-
case Some(recordingRep : EventRecordingReporter) =>
1217-
assert(recordingRep.testSucceededEventsReceived.size === 0)
1218-
val suiteAbortedEvents = recordingRep.suiteAbortedEventsReceived
1219-
assert(suiteAbortedEvents.size === 1)
1220-
suiteAbortedEvents(0).throwable match {
1221-
case Some(e: NotAllowedException) =>
1222-
assert(e.getMessage === Resources.notTheChosenStyle("org.scalatest.funsuite.AnyFunSuite", "org.scalatest.funspec.AnyFunSpec"))
1223-
case _ => fail("Expected SuiteAborted to carry NotAllowedException, but it did not.")
1224-
}
1225-
case _ => fail("Expected to find EventRecordingReporter, but not found.")
1226-
}
1227-
}
1228-
}
1229-
12301184
test("should fire SuiteAborted event when after function in BeforeAndAfter throws RuntimeException") {
12311185
val runner = framework.runner(Array("-C", classOf[EventRecordingReporter].getName), Array.empty, testClassLoader)
12321186
makeSureDone(runner) {

scalatest-test/src/test/scala/org/scalatest/tools/ScalaTestRunnerSuite.scala

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -256,52 +256,6 @@ import org.scalatools.testing.{Event, EventHandler, Result, Logger, Runner => Te
256256
}
257257
}
258258

259-
test("-y should do nothing when the task to execute is a chosen style") {
260-
val framework = new ScalaTestFramework()
261-
val runner: TestingRunner = framework.testRunner(Thread.currentThread.getContextClassLoader, Array(new TestLogger))
262-
val listener = new EventHandler {
263-
def handle(event: Event): Unit = {}
264-
}
265-
runner.run("org.scalatest.tools.scalasbt.SampleSuite", fingerprint, listener, Array("-y", "org.scalatest.funsuite.AnyFunSuite", "-C", classOf[EventRecordingReporter].getName))
266-
framework.RunConfig.reporter.get match {
267-
case Some(dispatchRep: DispatchReporter) =>
268-
dispatchRep.doDispose()
269-
dispatchRep.reporters.find(_.isInstanceOf[EventRecordingReporter]) match {
270-
case Some(recordingRep : EventRecordingReporter) =>
271-
assert(recordingRep.testSucceededEventsReceived.size === 3)
272-
assert(recordingRep.suiteCompletedEventsReceived.size === 1)
273-
case _ => fail("Expected to find EventRecordingReporter, but not found.")
274-
}
275-
case _ => fail("Expected to find DispatchReporter, but not found.")
276-
}
277-
}
278-
279-
test("-y should get SuiteAborted event with NotAllowedException when the task to execute is not a chosen style") {
280-
val framework = new ScalaTestFramework()
281-
val runner: TestingRunner = framework.testRunner(Thread.currentThread.getContextClassLoader, Array(new TestLogger))
282-
val listener = new EventHandler {
283-
def handle(event: Event): Unit = {}
284-
}
285-
runner.run("org.scalatest.tools.scalasbt.SampleSuite", fingerprint, listener, Array("-y", "org.scalatest.funspec.AnyFunSpec", "-C", classOf[EventRecordingReporter].getName))
286-
framework.RunConfig.reporter.get match {
287-
case Some(dispatchRep: DispatchReporter) =>
288-
dispatchRep.doDispose()
289-
dispatchRep.reporters.find(_.isInstanceOf[EventRecordingReporter]) match {
290-
case Some(recordingRep : EventRecordingReporter) =>
291-
assert(recordingRep.testSucceededEventsReceived.size === 0)
292-
val suiteAbortedEvents = recordingRep.suiteAbortedEventsReceived
293-
assert(suiteAbortedEvents.size === 1)
294-
suiteAbortedEvents(0).throwable match {
295-
case Some(e: NotAllowedException) =>
296-
assert(e.getMessage === Resources.notTheChosenStyle("org.scalatest.funsuite.AnyFunSuite", "org.scalatest.funspec.AnyFunSpec"))
297-
case _ => fail("Expected SuiteAborted to carry NotAllowedException, but it did not.")
298-
}
299-
case _ => fail("Expected to find EventRecordingReporter, but not found.")
300-
}
301-
case _ => fail("Expected to find DispatchReporter, but not found.")
302-
}
303-
}
304-
305259
test("-W should cause AlertProvided to be fired", Retryable) {
306260
val framework = new ScalaTestFramework()
307261
val runner: TestingRunner = framework.testRunner(Thread.currentThread.getContextClassLoader, Array(new TestLogger))

scalatest/src/main/scala/org/scalatest/AsyncEngine.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import java.util.ConcurrentModificationException
2222
import java.util.concurrent.atomic.AtomicReference
2323

2424
import org.scalactic.exceptions.NullArgumentException
25-
import org.scalatest.Suite.checkChosenStyles
2625
import org.scalatest.events.LineInFile
2726
import org.scalatest.events.Location
2827
import org.scalatest.events.SeeStackDepthException
@@ -528,9 +527,6 @@ private[scalatest] sealed abstract class AsyncSuperEngine[T](concurrentBundleMod
528527

529528
import args._
530529

531-
if (theSuite.testNames.size > 0)
532-
checkChosenStyles(configMap, theSuite.styleName)
533-
534530
// Wrap any non-DispatchReporter, non-CatchReporter in a CatchReporter,
535531
// so that exceptions are caught and transformed
536532
// into error messages on the standard error stream.

scalatest/src/main/scala/org/scalatest/Engine.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import java.util.ConcurrentModificationException
4343
import java.util.concurrent.atomic.AtomicReference
4444
import org.scalactic.exceptions.NullArgumentException
4545
import org.scalatest.PathEngine.isInTargetPath
46-
import org.scalatest.Suite.checkChosenStyles
4746
import org.scalatest.tools.Utils.wrapReporterIfNecessary
4847
import org.scalatest.events.LineInFile
4948
import org.scalatest.events.Location
@@ -451,9 +450,6 @@ private[scalatest] sealed abstract class SuperEngine[T](concurrentBundleModMessa
451450

452451
import args._
453452

454-
if (theSuite.testNames.size > 0)
455-
checkChosenStyles(configMap, theSuite.styleName)
456-
457453
// Wrap any non-DispatchReporter, non-CatchReporter in a CatchReporter,
458454
// so that exceptions are caught and transformed
459455
// into error messages on the standard error stream.

scalatest/src/main/scala/org/scalatest/FixtureSuite.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,12 @@ trait FixtureSuite extends org.scalatest.Suite { thisSuite =>
336336
*/
337337

338338
/**
339-
* Suite style name.
339+
* <strong>The <code>styleName</code> lifecycle method has been deprecated and will be removed in a future version of ScalaTest.</strong>
340340
*
341-
* @return `org.scalatest.FixtureSuite`
341+
* <p>This method was used to support the chosen styles feature, which was deactivated in 3.1.0. The internal modularization of ScalaTest in 3.2.0
342+
* will replace chosen styles as the tool to encourage consistency across a project. We do not plan a replacement for <code>styleName</code>.</p>
342343
*/
344+
@deprecated("The styleName lifecycle method has been deprecated and will be removed in a future version of ScalaTest with no replacement.", "3.1.0")
343345
override val styleName: String = "org.scalatest.FixtureSuite"
344346
}
345347

0 commit comments

Comments
 (0)