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

Documentation for DetachedMockFactory #1728

Merged
merged 13 commits into from
Jan 24, 2024

Conversation

AndreasTu
Copy link
Member

Added a new section "Create Mock Objects outside Specifications" in the interaction_based_testing.adoc to document usage of the DetachedMockFactory. Added reference to the new section to AutoAttach.

This fixes #1057

docs/interaction_based_testing.adoc Outdated Show resolved Hide resolved
docs/interaction_based_testing.adoc Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dd798eb) 80.44% compared to head (2cbab0a) 80.44%.

❗ Current head 2cbab0a differs from pull request most recent head a0ebad7. Consider uploading reports for the commit a0ebad7 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1728   +/-   ##
=========================================
  Coverage     80.44%   80.44%           
  Complexity     4336     4336           
=========================================
  Files           441      441           
  Lines         13529    13529           
  Branches       1705     1705           
=========================================
  Hits          10884    10884           
  Misses         2007     2007           
  Partials        638      638           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kriegaex
Copy link
Contributor

kriegaex commented Aug 6, 2023

@AndreasTu, thanks for taking the initiative here. I am not the type of person who comments in a code review, kinda remote-controlling and micro-managing my peers by telling the exactly which changes I suggest. I would rather opt to commit on top of your changes and collaborate with you that way. Would you mind giving me commit rights in your forked repo? Or would you rather have me create a forked PM, also on top of your changes? I am not a committer here, so the "Allow edits and access to secrets by maintainers" option does not have any effect on me, even though you might have activated it.

What I would change:

  • Adjust the wording a bit.
  • Provide a more insightful code example, showing users not just how they can use detached mocks, but also why they would want to do that in the first place, when outside of Spring or Guice.

@kriegaex
Copy link
Contributor

Sorry for being slow, @AndreasTu. I had noticed that you added me as a committer on your fork and started working on this PR a couple of days ago, but then was busy otherwise. Just now when trying to push my commit, I realised that I had to rebase first and that in the meantime you had also added an example for using a custom default response. My example is somewhat more verbose, also trying to create a sense of how to use it with a class under test and an injected mock. I also have an example for @AutoAttach. I hope that my changes are not too invasive. I think that your original PR's intent is still intact.

@leonard84, DYT it is OK to quote more code in the Spock manual? I felt like some snippets out of context might not do a proper job at explaining how to use detached mocks.

Copy link
Member

@leonard84 leonard84 left a comment

Choose a reason for hiding this comment

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

looking good, some things to refine

AndreasTu and others added 8 commits October 1, 2023 13:37
Added a new section "Create Mock Objects outside Specifications"
in the interaction_based_testing.adoc to document usage of the
DetachedMockFactory. Added reference to the new section to AutoAttach.

This fixes spockframework#1057
TODO: Find out why overriding default behaviour after attaching the
detached mock does not work as expected.
@AndreasTu AndreasTu self-assigned this Oct 1, 2023
AndreasTu and others added 3 commits January 24, 2024 20:31
…n/DetachedMockFactoryDocSpec.groovy

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
…n/DetachedMockFactoryDocSpec.groovy

Co-authored-by: Leonard Brünings <lord_damokles@gmx.net>
@leonard84 leonard84 enabled auto-merge (squash) January 24, 2024 20:48
@leonard84 leonard84 merged commit 0b5c4b5 into spockframework:master Jan 24, 2024
21 checks passed
@leonard84 leonard84 added this to the 2.4-M2 milestone Feb 22, 2024
@AndreasTu AndreasTu deleted the Docu_DetachedMockFactory branch August 18, 2024 09:09
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.

Documentation for DetachedMockFactory
3 participants