-
Notifications
You must be signed in to change notification settings - Fork 407
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
filter properties based on a criteria #267
Conversation
Hi @ssanj, If you're going to do this filtering by matching on test/property names, I think the What do you think? |
Hi @non, Thanks for your feedback.
We could pass the full match for the test name as well to -f, but that would only apply to what SBT hands over to ScalaCheck after filtering on test name. I thought this might be confusing to use as sometimes based on your SBT test name filter, your property name would not match any tests (because SBT has already filtered it out)
When running Scalacheck from the command line, we only specify a single test (currently - to mu knowledge) so I assumed there was no need to filter by test name. I'm not sure if there's a way to specify a wildcard for test name here?
So if we match on test name as well and run the filter from the command line, would we have to enumerate all the tests for the current project and then apply the test and property name filter to those found? I'm not sure what we would specify as the test name in this case?
One option would be to make the test name argument optional when specified with the -f option. Or we could use a wildcard:
What are your thoughts on this? |
@ssanj Ah, I hadn't thought about the fact that |
@non cool. Sounds good. I noticed that Travis had failed with some binary compatibility issues:
As I've added a new parameter to Test#Parameters and updated cp in the process, should I add this PR against another version branch? |
@ssanj As far as MiMA goes let's wait and see what @rickynils thinks. |
This looks useful! I think we should simply do 1.13.3 release, and then bump the master branch for 1.14 development. Then we can merge this and #263. I usually maintain a 1.13.x branch with back-ported stuff if needed, rather than creating a new branch for the next release. |
|
||
# ide | ||
*.ctags_srcs/ | ||
.tags |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ssanj Maybe those gitignore changes could be moved to another commit/PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rickynils sure.
1. Added filtering tests by regular expression 2. Removed .gitignore entries as per suggestion by @rickynils
Renamed runFilter => propFilter as it makes the intent clearer - filter properties on some predicate. Moved regular expression creation to outside of loops to reduce performance overhead.
Moved calculation of params out of loop to increase performance.
An initial assumption was that there was a 1:1 mapping between test class names and properties name. This is not true as multiple test classes can define the same properties. Eg: case PropObject extends Properties("TestSpecification") { def property1 = ... def property2 = ... def property3 = ... } case PropClass extends Properties("TestSpecification") { def property4 = ... } case OtherProp extends Properties("OtherSpecification") { def property3 = ... } This makes it hard to run all "TestSpecification" properties through SBT: test-only *Prop* //runs all tests in PropObject, PropClass and OtherProp This would result in output of the form: TestSpecification.property1 //from PropObject TestSpecification.property2 //from PropObject TestSpecification.property3 //from PropObject TestSpecification.property4 //from PropClass OtherSpecification.property3 //from OtherProp What if we want to only run property3 in TestSpecification? test-only *Prop* -- -f "property3" The above would result in output of the form: TestSpecification.property3 //from PropObject OtherSpecification.property3 //from OtherProp We don't want the OtherSpecification property included, but we have no way of filtering it out. As such it would be useful to allow filtering on the full property name which would include the grouping properties name as well as the property under test. This allows us to do: test-only *Prop* -- -f "TestSpecification\\.property3" This gives us the correct output: TestSpecification.property3 //from PropObject
02bde45
to
af16e6c
Compare
@non I've added in support for filtering on the Properties name as well on the property name as you requested before. I found some examples in ScalaCheck that use different test classes/specifications to define properties across the same Properties name. In those cases, SBT only filters on the class/specification name, which is different to the Properties name. I've added some thoughts on why in the comments to 3d5d030. |
Seems like Travis is having issues downloading dependencies:
|
@ssanj I think you can re-run Travis by closing and reopening (or @rickynils can re-run it directly). |
Closing (and will then reopen) to rerun Travis. |
@non The Binary compatibility checks still fail as I have changed the API. The other tests have passed. |
Looks good, thanks! |
Allows properties to be filtered based on a supplied criteria. This
allows running of a subset of property tests for a given specification.
The test criteria is specified by the '-f' option.
Eg:
Given the following properties for a String specification:
when supplied with a "map" criteria, Scalacheck will only run the map property:
On the commandline:
scala -cp scalacheck.jar:. StringProps -f "map"
Through SBT:
test-only *StringProps -- -f map
The primary motivation for creating this functionality was so that
I could selectively run a subset of properties that were expensive
to run every time. It also helps focus on the current property being
tested without having to run all properties of a specification each
time.
I'm not sure I have covered all the bases here - I have tested this
through SBT and the commandline, but I wonder if there are any other
scenarios I should test this through.
I'm happy to get some feedback on this and improve it as necessary.