Skip to content

Instantly share code, notes, and snippets.

@serinth
Created July 23, 2021 06:39
Show Gist options
  • Save serinth/727f7d52d066dc41a84905c762d1c721 to your computer and use it in GitHub Desktop.
Save serinth/727f7d52d066dc41a84905c762d1c721 to your computer and use it in GitHub Desktop.
Kotlin Test Private method
// buildVerifyEmailHTMLBody is the private method name. Takes on argument of String
val instance = SendGridEmailer(mock {})
val privateMethod = instance.javaClass.getDeclaredMethod("buildVerifyEmailHTMLBody", String::class.java)
privateMethod.isAccessible = true
val params = arrayOfNulls<Any>(1)
params[0] = "https://url/verify/token"
assertEquals(expected, privateMethod.invoke(instance, *params))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment