-
Notifications
You must be signed in to change notification settings - Fork 179
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
Spek Extensions #115
Comments
Suggestions/Questions:
|
Makes sense, I did it that way to differentiate normal "groups" and a specification. If it doesn't have any use case I'm glad to remove it.
Actually, internally we use the term scopes, should we use that instead?
One way we can do this is adding support for tags. Based on the tags present, the extension can apply itself or just ignore that group/test.
I still prefer being explicit on what extensions to apply. Specifications will be way too fragile if we automatically apply them, there might be instances where conflicts may happen. |
I've added a sample extension for some mocking framework. |
Finally got some time to work on this, initial proposal is now obsolete. Basically there will be no more annotations, we will just expose a way to listen to Spek's lifecycle. I also changed subject to be purely an extension. Will update the description for more details about the change. |
I've updated the description, opinions please? :) |
This introduces extensions in Spek, see #115 on how to implement one. It also includes the following changes: - Renamed several DSL classes (breaking change) - Reworked subject support as an extension - Rebrand lazy groups to action groups
This introduces extensions in Spek, see spekframework#115 on how to implement one. It also includes the following changes: - Renamed several DSL classes (breaking change) - Reworked subject support as an extension - Rebrand lazy groups to action groups
Spek lacks support for integrating third party libraries (Spring, PowerMock, etc ...), this is one of main the reasons why people can't move out from the JUnit 4 based runner.
At a minimum we should allow extensions access to the execution lifecycle.
DSL
DSL classes are renamed and will take advantage of Kotlin/KEEP#57 (eventually - need to wait until Kotlin
1.1
is used widely) and Kotlin/KEEP#25.Terminology
Scopes (blocks or whatever you want to call them)
LifecycleListener
Extensions are basically
LifecycleListener
s, which can only be registered on the outer-most block of your spec.Memoized values (LifecycleAware)
Values that are tied-up to your spec's lifecycle. To create one, use
memoized(mode, factory)
.CachingMode
Specifies how memoized values are cached.test
s underaction
scopes will always share the same instance, regardless of what mode is chosen upon creation.Memoized values should only be used inside
fixtures
(beforeEachTest
andafterEachTest
),action
andtest
scopes.InstanceFactory
Introduced for a very specific use-case, to load a spec using a custom classloader (
PowerMock
,Robolectric
, etc..). It should supportclass
andobject
(#109) instances. Annotate to your spec with@CreateWith(MyInstanceFactory::class)
.Sample Extensions
Subjects
Reworked subject support as an extension (requires #143).
API
DSL
Custom
Spek
classShared subjects
Internals
Usage
Just extend
org.jetbrains.spek.subject.SubjectSpek
instead ofSpek
.CalculatorSpec
AdvancedCalculatorSpec
Mockito
Usage:
Some DI framework
Usage
The text was updated successfully, but these errors were encountered: