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

[ANCHOR-518] Add @LockAndMockStatic and @LockStatic annotations #1167

Merged

Conversation

lijamie98
Copy link
Collaborator

@lijamie98 lijamie98 commented Oct 18, 2023

Description

Add @LockAndMockStatic and @LockStatic annotations. Instead of

class MyTest {
  @LockAndMockStatic([NetUtil::class]) 
  fun myTest(){
    lockAndMockStatic() {
      // my tests here
   }
  }
}

the test method can be annotated with @LockAndMockStatic

@ExtendWith(LockAndMockTest::class) 
class MyTest {
  @LockAndMockStatic([NetUtil::class]) 
  fun myTest(){
  }
}

Context

To simplify the lockAndMock function.

Testing

  • ./gradlew test

@lijamie98 lijamie98 marked this pull request as draft October 18, 2023 16:28
@lijamie98 lijamie98 marked this pull request as ready for review October 18, 2023 18:18
@lijamie98 lijamie98 changed the title Add @LockAndMockStatic and @LockStatic annotations [ANCHOR-518] Add @LockAndMockStatic and @LockStatic annotations Oct 18, 2023
Copy link
Contributor

@philipliu philipliu left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -22,8 +22,8 @@ class AuthHelperTest {
@ParameterizedTest
@EnumSource(AuthType::class)
fun `test AuthHeader creation based on the AuthType`(authType: AuthType) {
val calendarSingleton = mockk<Calendar>(relaxed = true)
lockAndMockStatic(Calendar::class) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be replaced by the annotation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably not. I think val calendarSingleton = mockk<Calendar>(relaxed = true) should happen before the mock.

Copy link
Contributor

Choose a reason for hiding this comment

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

Didn't notice that 👍

@lijamie98 lijamie98 merged commit eecc968 into stellar:develop Oct 18, 2023
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.

2 participants