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
I'm using FnProject now and I'm using external dependencies to access external resources and I'm trying to mock to test the function without dependencies in it. How should I mock my external resource?
public class FunctionTest {
@Rule
public final FnTestingRule testing = FnTestingRule.createDefault();
@Test
public void shouldReturnGreeting() {
testing.givenEvent().withBody("{\"data\":123}").enqueue();
testing.thenRun(Function.class, "handleRequest");
FnResult result = testing.getOnlyResult();
assertEquals("OK", result.getBodyAsString());
}
}
public class Function {
public ExternalResource getExternalResource() {
return new ExternalResource(); // how to mock this?
}
public String handleRequest(String inputData) {
var externalResource = getExternalResource();
externalResource.doSomething();
return "OK";
}
}
The text was updated successfully, but these errors were encountered:
Hi team,
I'm using FnProject now and I'm using external dependencies to access external resources and I'm trying to mock to test the function without dependencies in it. How should I mock my external resource?
The text was updated successfully, but these errors were encountered: