-
Notifications
You must be signed in to change notification settings - Fork 405
Verify only props matching the given TestSelectors #1031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
core/jvm/src/test/scala/org/scalacheck/ScalaCheckFrameworkSpecification.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* ScalaCheck | ||
* Copyright (c) 2007-2021 Rickard Nilsson. All rights reserved. | ||
* http://www.scalacheck.org | ||
* | ||
* This software is released under the terms of the Revised BSD License. | ||
* There is NO WARRANTY. See the file LICENSE for the full text. | ||
*/ | ||
|
||
package org.scalacheck | ||
|
||
import org.scalacheck.Prop.{all, proved} | ||
import sbt.testing.{Selector, SuiteSelector, TaskDef, TestSelector} | ||
|
||
object ScalaCheckFrameworkSpecification extends Properties("ScalaCheckFramework") { | ||
|
||
private val firstProp = "ScalaCheckFrameworkHelper.first prop" | ||
private val secondProp = "ScalaCheckFrameworkHelper.second prop" | ||
private val thirdProp = "ScalaCheckFrameworkHelper.third prop" | ||
|
||
property("all props with SuiteSelector") = all( | ||
getPropNamesForSelectors(List(new SuiteSelector)) == List(firstProp, secondProp, thirdProp), | ||
getPropNamesForSelectors(List(new SuiteSelector, new TestSelector(firstProp))) == List( | ||
firstProp, | ||
secondProp, | ||
thirdProp), | ||
getPropNamesForSelectors(List(new SuiteSelector, new TestSelector("no matches"))) == List( | ||
firstProp, | ||
secondProp, | ||
thirdProp) | ||
) | ||
|
||
property("only matching props with TestSelector") = all( | ||
getPropNamesForSelectors(List(new TestSelector(firstProp))) == List(firstProp), | ||
getPropNamesForSelectors(List(new TestSelector(secondProp))) == List(secondProp), | ||
getPropNamesForSelectors(List(new TestSelector(firstProp), new TestSelector(thirdProp))) == List( | ||
firstProp, | ||
thirdProp), | ||
getPropNamesForSelectors(List(new TestSelector("no matches"))) == Nil | ||
) | ||
|
||
private def getPropNamesForSelectors(selectors: List[Selector]): List[String] = { | ||
val framework = new ScalaCheckFramework() | ||
val runner = framework.runner(Array.empty, Array.empty, getClass.getClassLoader).asInstanceOf[ScalaCheckRunner] | ||
val taskDef = new TaskDef( | ||
classOf[ScalaCheckFrameworkSpecificationHelper].getName, | ||
framework.fingerprints()(0), | ||
true, | ||
selectors.toArray) | ||
val baseTask = runner.rootTask(taskDef) | ||
val newTasks = baseTask.execute(null, null) | ||
val propNames = for { | ||
task <- newTasks | ||
selector <- task.taskDef().selectors() | ||
} yield selector.asInstanceOf[TestSelector].testName() | ||
propNames.toList | ||
} | ||
} | ||
|
||
class ScalaCheckFrameworkSpecificationHelper extends Properties("ScalaCheckFrameworkHelper") { | ||
property("first prop") = proved | ||
property("second prop") = proved | ||
property("third prop") = proved | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.