Posty

Wyświetlanie postów z maj, 2018

AutoCodeCoverage - how it can help you find a bug

Obraz
Hi Last time I shown you what is AutoCodeCoverage. Today I would like to show you how it can help you. I'll show you how it can find small mistakes in you code. Let's start. Last time i shown my example solution which was covered in 100% by unit tests with AutoCodeCoverage.  There were 3 projects - SimpleClassLibrary, SimpleClassLibrary2 and UnitTestProject1. It looked like:  Now it looks like: I added more empty implementations of interface Inter1Lib2 and change logic of Class2. Old Class2 was looking like this: namespace SimpleClassLibrary { public class Class2 { public void HowIWasCreated(Class1 cl) { if (cl == null) { Console.WriteLine("null"); return; } if (cl.HowCreated() == EnumHowCreated.DefaultConstructor) { Console.WriteLine("Default"); } if (cl.HowCreated() == EnumHowCreated.ParameterConstructor) { Console.WriteLine("Paramet

AutoCodeCoverage - nuget package for covering .net code with tests

Obraz
Hi I was wondering for some time about code coverage in c#. I'm using a lot of DTO objects which should be covered by unit tests. I thought that it should be covered by default. I wrote simple project FakeCodeCoverage. It used reflection to cover the simplest way in constructors and methods. It was not enough for me. It was really only fake coverage. I abandoned this project but I started new project AutoCodeCoverage. This is different from the previous one because it tries cover all statements, branches and conditions. As result you can get all exceptions which was thrown while invoking methods, constructors, properties, etc. It allows to inject implementation of interface or instance of type which will be used at all times when this type will be exist as parameter. In DTOs or simple projects AutoCodeCoverage could cover up to 100% lines of your code. It is published on nuget https://www.nuget.org/packages/AutoCodeCoverage Actually it support .net4.x, .netcore