Comments (9)
I like the idea.
On 27 June 2016 at 21:21, Christian Helmbold [email protected]
wrote:
At the moment config is only available per test case. But it would be
useful to have a configuration per specification class, that could be
overridden per test case if necessary. My suggestion is as follows:Instantiating a TestConfig object directly and assign it to an overridden
property :class MySpec : StringSpec() {
override val config = TestConfig(threads = 10, invocations = 100)
...
}or using a factory method instead of a direct instantiation:
class MySpec : StringSpec() {
override val config = config(threads = 10, invocations = 100)
...
}(If TestConfig would be renamed to just Config both variants were almost
the same from a users perspective.)Another option would be to call a config method inside the init block and
don't use an overridden property, but I prefer a property.class MySpec : StringSpec() {
init {
config(threads = 10, invocations = 100)... }
}
I think a class wide configuration should reside on the class level as in
the examples with the property.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#44, or mute the thread
https://github.com/notifications/unsubscribe/AAtZGgQ_DB4aKlu0l0dP6SjTe7LrtgpQks5qQDDfgaJpZM4I_eEb
.
from kotest.
What variant do you prefer? Or do you have another suggestion?
from kotest.
I think the override fits in better with the afterAll, oneInstance, etc
On 27 June 2016 at 21:25, Christian Helmbold [email protected]
wrote:
What variant do you prefer? Or do you have another suggestion?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#44 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAtZGsh0puq_u8f2rnJMozm3r2OHI1J5ks5qQDHQgaJpZM4I_eEb
.
from kotest.
Ok, following this approach, it would be consistent to leave out config
and provide properties like threads
or ignored
directly:
class MySpec : StringSpec() {
override val threads = 10
override val invocations = 100
override val ignored = true
...
}
What do you think?
from kotest.
I guess that is consistent, but then again the DSL style can be more powerful. I guess we can always add more later.
Let's go with the overrides.
from kotest.
OK, we agree that overrides are the best way. But after some time thinking about it, I tend to use override with the TestConfig
object or config
method, since a property like threads
doesn't belong to the specification class itself. Whereas oneInstancePerTest
does belong to the class. So it could be confusing to have per class and per test case parameters at the same level. To be self explanatory it would need a name like threadsPerTestCase
or something like that. And then it would be better to use a config object with a property name that makes clear that this config is per test case and not per class. My preferred way is this:
class MySpec : StringSpec() {
override val defaultTestCaseConfig = config(threads = 10, invocations = 100)
...
}
I think using a config
factory method would be good, so that we would have the same syntax as for configuration per test case. Less to remember is better.
from kotest.
Ok I think we can go with that.
On 28 June 2016 at 10:47, Christian Helmbold [email protected]
wrote:
OK, we agree that overrides are the best way. But after some time thinking
about it, I tend to use override with the TestConfig object or config
method, since a property like threads doesn't belong to the specification
class itself. Whereas oneInstancePerTest does belong to the class. So it
could be confusing to have per class and per test case parameters at the
same level. To be self explanatory it would need a name like
threadsPerTestCase or something like that. And then it would be better to
use a config object with a property name that makes clear that this config
is per test case and not per class. My preferred way is this:class MySpec : StringSpec() {
override val defaultTestCaseConfig = config(threads = 10, invocations = 100)
...
}I think using a config factory method would be good to have the same
syntax as for configuration per test case. Less to remember is better.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#44 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AAtZGvTFk2_WLoQi4iY6j0bZ8UBVp5l7ks5qQO21gaJpZM4I_eEb
.
from kotest.
OK, I'll implement as suggested.
from kotest.
I've made TestConfig
immutable to avoid strange behavior I've discovered while developing. We should try to make as much as possible immutable.
from kotest.
Related Issues (20)
- Do Kotlin/JS tests run?
- `filterIsInstance()` for `Arb` requires both type arguments compared to stdlib `filterIsInstance()`
- kotest-assertions-ktor: Fix failure message
- `row` toString() considered "unstable" even if all type parameters are clearly stable
- `shouldContain` always matches against `null` map value HOT 2
- Adapt assertion extensions for Collections and Iterables to use bounded types HOT 3
- Lifecycle hooks with mockk do not work properly on `object` and java classes with static functions HOT 12
- kotest-extensions-mockserver v1.3.0 is incompatible with kotest v5.8.1
- Link `table_driven_testing.md` file to `sidebar_label`
- Test names containing line breaks are ignored when run individually
- Support setting retry config via `AbstractProjectConfig` HOT 3
- coroutineTestScope: timeout for TestDispatcher cannot be configured HOT 10
- containExactly* assertions don't respect given verifier HOT 4
- Tests get run multiple times when using maxParallelForks HOT 20
- add matcher shouldContainJson HOT 4
- In `isolationMode = InstancePerTest`, `afterSpec` is not called after mid-level containers HOT 3
- Kotlin/JS 2.0.0-RC1 Incompatibilities (environmental variables not working, error output not printed) HOT 1
- Can I use prepareSpec without @AutoScan? HOT 8
- Assertion JSON shouldcontainjsonkeyvalue should support filter results as value HOT 7
- Arb.list fails within edge cases in case of null values HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kotest.