Skip to content

Instantly share code, notes, and snippets.

@slorber
Last active August 29, 2015 14:07
Show Gist options
  • Save slorber/83b3b3a672dac9604b6e to your computer and use it in GitHub Desktop.
Save slorber/83b3b3a672dac9604b6e to your computer and use it in GitHub Desktop.
[stample-web] $ it:testOnly *CategoryService*
Extract /home/sebastien/.embedmongo/linux/mongodb-linux-x86_64-2.4.10.tgz START
Extract /home/sebastien/.embedmongo/linux/mongodb-linux-x86_64-2.4.10.tgz DONE
Oct 16, 2014 10:43:24 AM MongodExecutable start
INFO: de.flapdoodle.embed.mongo.config.MongodConfigBuilder$ImmutableMongodConfig@27514bba
STARTED EMBEDDED MONGODB
[info] service.CategoryServiceTest
[info] CategoryServiceTest
[info]
[info] CategoryService service getSubCategories(user,categoryId) should
[info] + get the subcategories for category owner
[info] + not get the subcategories for a random user
[info] + get the subcategories for an user having category permission, with breadcrumb not including non-shared categories
[info]
[info] CategoryService moveCategoryV2 should
[info] + permit to move a category inside another
[info] + permit to move a category inside a deep category
[info] + permit to move a deep category to the root
[info] + not permit to move a category inside itself
[info] + not permit to move a category inside its parent (as it's already there!)
[info] + not permit to move a category inside one of its childs
[info] + permit to move a shared category's child to another category's child
[info] + permit to move a shared category's child in another shared category
[info] + permit to move a shared category's child in another shared category's child
[info] x not permit to move a shared category in another shared category
[error] 'Right([Category=543f8530327c21efa8d458d2 - [Home>Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:251)
[info]
[info] x not permit to move a shared category in another shared category's child
[error] 'Right([Category=543f8530327c21efa8d458e8 - [Home>Sub Home>Sub Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:263)
[info]
[info] + not permit to move my category to an unshared category of another user
[info] + not permit to another user's unshared category to my category
[info] + not permit to move home into another user's shared category with READ permissions
[info] + not permit to move home into another user's shared category with WRITE permissions
[info] + not permit to move home into another user's shared category with MANAGE permissions
[info] + not permit to move home (with shared childs) into another user's shared category with READ permissions
[info] + not permit to move home (with shared childs) into another user's shared category with WRITE permissions
[info] + not permit to move home (with shared childs) into another user's shared category with MANAGE permissions
[info] + not permit to move my category into another user's shared category with READ permissions
[info] + permit to move my category into another user's shared category with WRITE permissions
[info] + permit to move my category into another user's shared category with MANAGE permissions
[info] + not permit to move my shared category into another user's shared category with READ permissions
[info] x not permit to move my shared category into another user's shared category with WRITE permissions
[error] 'Right([Category=543f8531327c21efa8d45a70 - [Home>Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:311)
[info]
[info] x not permit to move my shared category into another user's shared category with MANAGE permissions
[error] 'Right([Category=543f8531327c21efa8d45a90 - [Home>Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:311)
[info]
[info] + not permit to move my shared category's child into another user's shared category with READ permissions
[info] + permit to move my shared category's child into another user's shared category with WRITE permissions
[info] + permit to move my shared category into another user's shared category with MANAGE permissions
[info] + not permit to move my category containing shared childs into another user's shared category with READ permissions
[info] x not permit to move my category containing shared childs into another user's shared category with WRITE permissions
[error] 'Right([Category=543f8532327c21efa8d45b34 - [Home>Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:311)
[info]
[info] x not permit to move my category containing shared childs into another user's shared category with MANAGE permissions
[error] 'Right([Category=543f8532327c21efa8d45b55 - [Home>Sub Home>Sub Home]])' is not Left (CategoryServiceTest.scala:311)
[info]
[info] + not permit to move a shared category of another user with READ permission
[info] x not permit to move a shared category of another user with WRITE permission
[error] 'Right([Category=543f8532327c21efa8d45b9e - [Home>Sub Home]])' is not Left (CategoryServiceTest.scala:486)
[info]
[info] x not permit to move a shared category of another user with MANAGE permission
[error] 'Right([Category=543f8532327c21efa8d45bbd - [Home>Sub Home]])' is not Left (CategoryServiceTest.scala:486)
[info]
[info] + not permit to move a shared category's child of another user that he created, with READ permission
[info] + permit to move a shared category's child of another user that he created, with WRITE permission
[info] + permit to move a shared category's child of another user that he created, with MANAGE permission
[info] + not permit to move a shared category's child of another user I he created, with READ permission
[info] + permit to move a shared category's child of another user that I created, with WRITE permission
[info] + permit to move a shared category's child of another user that I created, with MANAGE permission
[info]
[info] Total for specification CategoryServiceTest
[info] Finished in 6 seconds, 611 ms
[info] 43 examples, 8 failures, 0 error
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] x service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info] + service.CategoryServiceTest
[info]
[info]
[info] Total for test service.CategoryServiceTest
[info] Finished in 7.543 seconds
[info] 43 tests, 8 failures, 0 errors
SHUTDOWN EMBEDDED MONGODB
Oct 16, 2014 10:43:31 AM de.flapdoodle.embed.mongo.AbstractMongoProcess stopInternal
INFO: try to stop mongod
Oct 16, 2014 10:43:31 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/embedmongo-db-86c3cd73-72fb-4f25-9a98-10f68b2c8a79
Oct 16, 2014 10:43:31 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/extract-sebastien-mongod.pid
[error] Failed: Total 43, Failed 8, Errors 0, Passed 35
[error] Failed tests:
[error] service.CategoryServiceTest
[error] (stample-web/it:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 10 s, completed Oct 16, 2014 10:43:31 AM
[stample-web] $ Oct 16, 2014 10:43:32 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/extract-sebastien-mongod
[stample-web] $ it:testOnly *CategoryService* -- -ex ".*"
Extract /home/sebastien/.embedmongo/linux/mongodb-linux-x86_64-2.4.10.tgz START
Extract /home/sebastien/.embedmongo/linux/mongodb-linux-x86_64-2.4.10.tgz DONE
Oct 16, 2014 10:44:40 AM MongodExecutable start
INFO: de.flapdoodle.embed.mongo.config.MongodConfigBuilder$ImmutableMongodConfig@467a68f5
STARTED EMBEDDED MONGODB
[info] service.CategoryServiceTest
[info] CategoryServiceTest
[info]
[info]
[info] CategoryService service getSubCategories(user,categoryId) should
[info]
[info]
[info]
[info]
[info] CategoryService moveCategoryV2 should
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info]
[info] Total for specification CategoryServiceTest
[info] Finished in 221 ms
[info] 0 example, 0 failure, 0 error
[info]
[info]
[info] Total for test service.CategoryServiceTest
[info] Finished in 1.042 seconds
[info] 0 tests, 0 failures, 0 errors
SHUTDOWN EMBEDDED MONGODB
Oct 16, 2014 10:44:42 AM de.flapdoodle.embed.mongo.AbstractMongoProcess stopInternal
INFO: try to stop mongod
Oct 16, 2014 10:44:42 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/embedmongo-db-ab3f9072-d17d-4dd6-8a0f-35adaaf719d5
Oct 16, 2014 10:44:42 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/extract-sebastien-mongod.pid
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 3 s, completed Oct 16, 2014 10:44:42 AM
[stample-web] $ Oct 16, 2014 10:44:49 AM de.flapdoodle.embed.process.io.file.Files forceDelete
INFO: Could delete /tmp/extract-sebastien-mongod
@slorber
Copy link
Author

slorber commented Oct 16, 2014

No quotes: test-only * -- -ex .*diacritics.*: NOK
No dash: test-only * -- ex .*diacritics.*: OK
Additional double-dash: test-only * -- -ex .*diacritics.* --: OK

No quotes: it:test-only *CategoryService* -- -ex .*deep.*: NOK
No dash: it:test-only *CategoryService* -- ex .*deep.*: OK
Additional double-dash: test-only *CategoryService* -- -ex .*deep.* --: OK

So it seems weird but the last solution does not work with my it config.
The "no dash" solution works fine with both configs, and works with quotes too (however I'm not sure of the behavior I see when using spaces in the regex)

Thanks :)

@etorreborre
Copy link

Good to know that you have a solution. Just a note: arguments passing is a bit ad-hoc and primitive in specs2. Historically only ex was there but you could not use spaces (I actually think it is a bug now I should look into it). Then I added -ex aaaa bbb ccc where aaaa bbb ccc would be caught as the argument for -ex and if you wanted to add other arguments you would have to add --: -ex aaaa bbb ccc -- sequential. I'll put a note for myself to at least document that in the next version.

@slorber
Copy link
Author

slorber commented Oct 16, 2014

but it is kind of hard to match exemples with spaces.

it:test-only service.CategoryServiceTest -- ex "not permit to move a category inside itself"

It seems like it matches on .*not.*, only the first term is taken.

I have to do:
it:test-only service.CategoryServiceTest -- ex "not\\spermit\\sto\\smove\\sa\\scategory\\sinside\\sitself"

So for long strings where many special regex chars, it forces me to add some "key" to my exemples to be able to match them easily.

So I think it may be cool to have some feature, a bit like pendingUntilFixed but the opposite, something like executeThisExempleButNotOthers.
This would be cool to easily be able to focus on a given test to debug it.

You have to recompile the test, but at least it would be easier than having to find the appropriate regexp in some cases.

@etorreborre
Copy link

Note that a very low-tech alternative to this is to add on special character to your description, like @ and go test-only -- ex @.

@slorber
Copy link
Author

slorber commented Oct 17, 2014

Note that moving from dependency specs2 to specs2-core has broken my unit tests (but not my integration tests).

java.lang.NoSuchMethodError: org.specs2.runner.Fingerprints$.fp1()Lorg/specs2/runner/SpecificationFingerprint;
    at org.specs2.runner.Specs2Framework.fingerprints(SbtRunner.scala:23)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)

Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment