8000 [Feature] Implement BDD-style aliases as separate module (mockk-bdd) by Minseok-2001 · Pull Request #1399 · mockk/mockk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Feature] Implement BDD-style aliases as separate module (mockk-bdd) #1399

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Minseok-2001
Copy link
@Minseok-2001 Minseok-2001 commented May 24, 2025

Implement BDD style aliases as separate modules

This PR implements BDD (Behavior-Driven Development) style API for MockK as proposed in issue #439. The implementation provides aliases for existing MockK functions with BDD-oriented naming

  • given (alias for every)
  • coGiven (alias for coEvery)
  • then (alias for verify)
  • coThen (alias for coVerify)

Following discussions in PR #662, these aliases are implemented as separate modules to avoid confusion and maintain code consistency.

New Modules

  • mockk-bdd: Base module with BDD style aliases
  • mockk-bdd-android: Android-specific module (but... just wrapping mockk-bdd 😂)
    Separate Modules: As suggested in PR [#439] Implement BDD style alias methods #662 discussion, BDD aliases are implemented as separate modules to
  • Avoid confusion with existing APIs
  • Allow teams to choose their preferred style
  • Maintain code consistency in projects

Usage

// Regular MockK
testImplementation("io.mockk:mockk:x.y.z")

// Add BDD style
testImplementation("io.mockk:mockk-bdd:x.y.z")

// For Android
androidTestImplementation("io.mockk:mockk-bdd-android:x.y.z")

Example

// Given
given { myService.getValue() } returns "test value"

// When
val result = myService.getValue()

// Then
then { myService.getValue() }
assertEquals("test value", result)

Testing

  • Added comprehensive tests for all BDD functions
  • Verified compatibility with existing MockK functions
  • Tested locally via publishToMavenLocal and confirmed functionality in sample project

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.

1 participant
0