A couple of weeks ago a friend ask if I had tested GitHub Copilot, I had not. I had seen information about it flash by but dismissed it as another technology that promises a lot but deliver very little. But my friend told me to try it out and that I would be surprised.
So I created my account at GitHub Copilot over the weekend and then activated the GitHub Copilot extension in Visual Studio Code and Visual Studio. At the time I was working on a side-project and all of a sudden I no longer needed to write code!
Copilot Writing Bicep
My first test was writing Bicep in Visual Studio Code. I created a new file, added two variable and then started writing something like resource storageAccount
and Copilot presented me with a suggestion so the rest of the code was written by my pressing Tab. Amazing!
Example Writing Web API
Example Writing Test Cases
I also tried Copilot when writing test cases by creating the method signature public void ReadArtportalen_Failed_Storage
. I had done two previous methods that involved success cases with Arrange
parts that started identical to what Copilot generated, but the impressive part was that Copilot was able to understand part the purpose of the test through the method name and add a completely new piece of code that I had not written earlier:
mockStorageAccountRepository.Setup(x => x.SaveObservations(It.IsAny>())).Throws(new Exception("Failed to save to storage"));
As you can see it understood that I wanted the mock of the StorageAccountRepository to send on exception. And if you look closely in the image below you can see that it also adjusted the test so that it verify that ServiceBusRepository.SendMessageToQueue
is never called (because an exception is thrown before reaching it).