.NET 1.0.1 Unit test strategy #4575
-
I am working on upgrading 1.0.0-beta8 to 1.0.1, and I found it is not possible to mock Kenel, Function, or Pluggin. For example I have an extension function that my business logic calling to:
In 1.0.0-beta8, I was able to mock I am currious how you guys do it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Does anyone know how to setup the mock for InvokeAsync? this.kernelMock.Setup(k => k.InvokeAsync(It.IsAny(), It.IsAny())).ReturnsAsync(It.IsAny()); this is throwing an error and I am not able to mock the call. |
Beta Was this translation helpful? Give feedback.
-
Per @markwallace-microsoft guidance on #4589, you can take a look at our existing unit tests here for KernelFunctionFromMethodTests1.cs For your use case you can mock the AI service and add that to the Kernel you use in your unit tests. We're going to take a look at providing guidance around unit testing. |
Beta Was this translation helpful? Give feedback.
-
@jimmy-vo-librestream @pratibw Here is a blog post about unit testing of Semantic Kernel components: Hope it will help! |
Beta Was this translation helpful? Give feedback.
Per @markwallace-microsoft guidance on #4589, you can take a look at our existing unit tests here for
KernelFunction
:KernelFunctionFromMethodTests1.cs
KernelFunctionFromMethodTests2.cs
KernelFunctionFromPromptTests.cs
For your use case you can mock the AI service and add that to the Kernel you use in your unit tests. We're going to take a look at providing guidance around unit testing.