Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@alfonsoristorato
Copy link
Contributor

@alfonsoristorato alfonsoristorato commented Oct 18, 2025

introduces withXXX for each combination in behaviour spec - there will be follow up PRs for the remaining of specs.
Docs can potentially be updated in a final PR

@AlexCue987
Copy link
Member

is it still a draft?

@alfonsoristorato
Copy link
Contributor Author

is it still a draft?

I'd say so, we are discussing it in the other pr :)

@alfonsoristorato alfonsoristorato changed the title Specific data test methods for all Specs Specific data test methods for behaviour spec Oct 20, 2025
@sksamuel
Copy link
Member

lgtm,

should we go away and add a simpler one too to iron out any incompatibilities ?

@sksamuel
Copy link
Member

Also can we not merge this until 6.0.5 has been released, as we should put this only in the 6.1.0 release.

@alfonsoristorato
Copy link
Contributor Author

alfonsoristorato commented Oct 20, 2025

Sounds good re waiting 6.1.0, in that case, would you rather have all the code changes in this pr, so to avoid pr overload ?

@sksamuel
Copy link
Member

Your call - happy for one big one if that saves you sequencing headaches.

Should we add some tests around beforeEach, beforeAny, beforeAll and how they now interact with withXXX ?

I wonder if there's any code to be saved by parameterizing them like we did for test config?
So that withContexts delegates to a withContainerDataTest method that just takes a type parameter for the concrete type it delegates to (similar to your original idea, but means that anyone can extend their own spec style easily if needed). I would only consider doing this if you think it saves you some lines of code overall.

@alfonsoristorato
Copy link
Contributor Author

should we go away and add a simpler one too to iron out any incompatibilities ?

stringSpec added to this PR with withTests

Should we add some tests around beforeEach, beforeAny, beforeAll and how they now interact with withXXX ?

I have added some tests for this, it's particularly visible that beforeEach like before counts only before every Container level test and beforeAny before any test, whether Container or Test scopes.

I wonder if there's any code to be saved by parameterizing them like we did for test config?

I don't think we can get any gainings by parameterizing this at this level, as in, I can parameterize it but the DSL will still need to be repeated for every spec, if anything it might add more code into the mix.

@sksamuel
Copy link
Member

Ok cool. I wonder if we shouldn't even bother with StringSpec, kinda seems pointless to mix up plain strings with function calls. Same for free spec? Thoughts ?

@alfonsoristorato
Copy link
Contributor Author

Ok cool. I wonder if we shouldn't even bother with StringSpec, kinda seems pointless to mix up plain strings with function calls. Same for free spec? Thoughts ?

That's fair, I will bring it back to withData, as long as we keep withData alive tho, these are my favourite specs :)

@alfonsoristorato alfonsoristorato changed the title Specific data test methods for behaviour spec Specific data test methods for various specs Oct 25, 2025
@alfonsoristorato
Copy link
Contributor Author

@sksamuel and @AlexCue987 all possible specs are done - please have a look and if we are all happy I can do the docs

Comment on lines +39 to +40
// only counting tests within the shoulds
beforeEachCounter shouldBe 36
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was quite interesting, beforeEach is only called for tests within the should - i.e. this, this and this

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants