Mockk Error in android Koltin Unit test. matching with Two URL
io.mockk.MockKException: Missing mocked calls inside every { ... } block: make sure the object inside the block is a mock
@Before
fun setUp() {
mockkStatic(Uri::class)
every { Uri.parse(any()) } returns mockk()
every { Uri.Builder() } returns mockk()// Error occurred here
MockKAnnotations.init(this, relaxUnitFun = true)
}
@Test
fun isParamTest() {
every { Uri.parse(any()) } returns mockk(relaxed = true)
every { Uri.Builder() } returns mockk(relaxed = true)
val inputURL ="https://test"
val expected="https://test"
parameterKey="test",value="testvalue"
val Output = getWebURL(inputURL,parameterKey,value)
assertThat(Output).isEqualTo(expected)
}
private Uri buildURI(String url, Map<String, String> params) {
// build url with parameters.
Uri.Builder builder = Uri.parse(url).buildUpon();
for (Map.Entry<String, String> entry : params.entrySet()) {
builder.appendQueryParameter(entry.getKey(), entry.getValue());
}
return builder.build();
}
Thanks in Advance
Need to solve this unit test case