Skip to main content

Posts

Showing posts with the label unittest

JavaScript, Unit Test, Visual Studio and Build Machine Integration

Today I will write a short post about JavaScript and unit testing. I heard a lot of .NET developers that they didn’t wrote code for JavaScript because is not supported by Visual Studio, is complicated to run it on the build machine or they don’t have time. Guys, I have news for you, Visual Studio 2012 supports unit tests for JavaScript, even Visual Studio 2010. You can run them almost like a normal unit test for C# without needing to install anything. The JavaScript unit tests are so smart that are integrated in a way that you don’t need to change/install anything on your build machine – you even receive the standard message notification when a unit test fail. You don’t have time for them – I will not comment this, definition of DONE is wrong for those developers. When I need to write unit tests for JavaScript code I usually prefer qunit. Why? Because in combination with a small NuGet package called NQunit you can make magic. qunit give you the possibility to write and run Java...

Add files to unit tests output - DeploymentItem

Uneori când scriem unit teste avem nevoie sa specificam anumite fișiere care sa fie copiate în directorul de unde rulează testele. Cea mai simpla variante este sa adaugăm aceste fișiere în *.testsettings (la secțiunea Deployment). Dar dacă vrem sa specificam aceste dependințe separat, pentru fiecare unit test în parte? Putem sa facem acest lucru folosindu-ne de atributul DeploymentItem . Acesta poate sa fie specificat per clasa sau metoda de unit test. Putem sa specificam ce fișier sa se copieze în output și opțional și sub ce director. [TestClass] [DeploymentItem("text.txt")] public class ATest { [TestMethod] public void M1Test() { ... } } In cazul în care vrem sa specificam un director sa fie copiat 1 la 1 în output-ul pentru teste este nevoie sa specificam doar numele la director. [TestClass] [DeploymentItem("DirNameSource","DirNameDestination")] public class ATest { [TestMethod] public void M1Test() { ... } } In exemplul de mai sus am...