You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the test case, I am trying to mock the SecretConfig.apply() so that it does not make a real-time call while executing the same -
class SacSAAgentSoftwareLogParserTest extends AnyFlatSpec with Matchers with MockitoSugar {
"SacSAAgentSoftwareLogParser" should "execute the main method and process data correctly" in {
val intermediateSecretMap: collection.Map[String, String] = Map( "secret1" -> "value1")
withObjectMocked[SecretConfig.type] {
when(SecretConfig.apply()).thenReturn(intermediateSecretMap)
}
...
SacSAAgentSoftwareLogParser.main(Array.empty)
...
However, the mocking does not really work while running the test case. Instead, it goes on to call the SecretConfig.apply() in real time. I have added that mock-maker-inline thing in src -> test -> resources -> mockito-extensions -> org.mockito.plugins.MockMaker.
Definitely I'm doing some mistakes here, just not able to figure out what they are. There might be some gap in my understandings as well.
The text was updated successfully, but these errors were encountered:
I have started working in Scala very recently. I have below code in the main method that I'll need to mock for writing test cases,
Here is how the object SecretConfig is defined. It reads configs from HC Vault.
In the test case, I am trying to mock the SecretConfig.apply() so that it does not make a real-time call while executing the same -
However, the mocking does not really work while running the test case. Instead, it goes on to call the SecretConfig.apply() in real time. I have added that mock-maker-inline thing in
src -> test -> resources -> mockito-extensions -> org.mockito.plugins.MockMaker
.Definitely I'm doing some mistakes here, just not able to figure out what they are. There might be some gap in my understandings as well.
The text was updated successfully, but these errors were encountered: