How to write xUnit test for my controller #560
Replies: 1 comment
-
Ok, better to mock all this stuff and just test Reconcile method. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I am using KubeOps as nuget package and have e.g. my own controller:
public class RecorderController : IResourceController<RecorderSettings>
Now I want to write a xUnit test for this controller, I have added xUnit test project, added KubeOps.Testing nuget package to it and stuck a bit on creating TestStartup.cs class like mentioned here:
https://github.com/buehler/dotnet-operator-sdk/blob/master/src/KubeOps.Testing/README.md
I have found some example here:
https://github.com/buehler/dotnet-operator-sdk/blob/de75f4a5e1b875fe86bb92c5467a19c2e92c07c5/tests/KubeOps.TestOperator.Test/TestStartup.cs
but this doesn't seem to explain what I need to do to create my own test.
Also, this line in example:
_factory = factory.WithSolutionRelativeContentRoot("tests/KubeOps.TestOperator");
does it means that to write xUnit test I need to download and reference all KubeOps sources?
Also, IControllerInstanceBuilder and IManagedResourceController are internal classes inside KubeOps projects, so how they can be used in xUnit test?
Is KubeOps.Testing nuget package + reference to my .net project with RecorderController definition enough to write a test or not?
Best regards,
Victor
Beta Was this translation helpful? Give feedback.
All reactions