Skip to content
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

add get method that returns the subject #244

Closed

Conversation

christophsturm
Copy link
Contributor

No description provided.

@dave08
Copy link

dave08 commented Apr 29, 2021

Isn't this already possible with and { }? And doing expectThat(subject.name)... looks a bit simpler?

@christophsturm
Copy link
Contributor Author

christophsturm commented Apr 29, 2021

the use case is to split big expectThat blocks into smaller blocks.
and to simplify code like this:

                describe("get routes") {
                    expectThat(routes).getValue(Method.GET).hasSize(2)
                    val getRoutes = routes[Method.GET]!!
                    it("adds a get detail route") {

to
val getRoutes= expectThat(routes).getValue(Method.GET).hasSize(2).get()

@dave08
Copy link

dave08 commented Apr 29, 2021

Oh! An expect in describe, that seems to not conform with AAA (Arrange Act Assert)? I usually have them only in it blocks... then asserting deeper is easier with and { }. And anyways after a bit more chaining, it can get confusing to see what that's actually returning... but I see the point a bit better now.

@christophsturm
Copy link
Contributor Author

well in failfast there is no strict separation between contexts and tests, so you can put asserts in the context, if it fails the context counts as 1 failed test. and in the child tests you then assert more on specifics for that one property that the test asserts.

the main point of the new get() method is to make it possible to use strikt to safely navigate object graphs.

@robfletcher
Copy link
Owner

I think this is a pretty radical change to Strikt's encapsulation. In some ways it would make writing tests with Strikt vastly easier because there would just be no need for all the mapping functions. At that point I wonder if we're talking about a different assertion library, though.

@christophsturm
Copy link
Contributor Author

yeah i know its a bit radical but we talked about it already some time ago on slack. For me it does not make strikt's navigation obsolete, it makes strikts safe navigation easier accessible.

I thought it could be a first step to simplify assertions, but it will really show when after writing tests with this feature for some time.

robfletcher added a commit that referenced this pull request Jul 12, 2021
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