Showing posts from 2023

Using AI tooling for unit testing in JetBrains Rider

Introduction I used Visual Studio and GitHub Copilot in the last blog post to generate unit test code. Many developers use Visual Studio, but JetBrains Rider is also used by many. I use JetBrains Rider a lot, especially when working on my MacBook. In this blog post, I will show you what the new code-generation AI features (AI Assistant) of JetBrains Rider can do for you as a developer. I used the 2023.2 version on a MacBook Pro M1 for this post. The AI tooling is still in preview and not available to the general public. The pricing of the AI plugin is also not known at this time. Example The example for this blog post is the same as the example for the blog post about Visual Studio and GitHub Copilot. To refresh your memory, or if you have not read the previous blog post, here is a small summary of our test case. For this article, I use a probably well-known example of an order with orderlineitems. Just as in the previous blog post, I asked the AI tooling to generate a property to calc

Writing unit tests with GitHub Copilot

Introduction A lot of developers do not like to write unit tests. Generative AI tools like GitHub Copilot can help you write unit tests. At least that is what these tools promise. In this blog post, I will write some unit tests using Github Copilot (with Chat) for a simple example to check if the promise is kept and what kind of changes to the generated code I have to make as a developer to get decent unit tests. Example For this blog post, I will use a probably familiar example of order and orderline items.  First tests  This code does not have a lot of logic to test. So let's add some logic to the order class. I ask GitHub Copilot to generate the code for calculating the total price for an order. In this code, I also changed the public list into a private one.   I can now ask Copilot to generate a unit test for this code using the prompt: "Can you generate a xunit test for the order and orderlineitem class where the order has 2 orderlineitems". Three unit tests were gen