In this webinar, Gil Zilberfeld talks with Dror Helper on how to start the process of unit testing. And be successful in the process.
This presentation contains information about the steps and pitfalls that you’ll probably encounter. Dror talks about tools, processes and the needed environment.
You can download the presentation from here.
The values of unit testing like shortening the development time, reducing development costs and releasing higher quality products, are well known. Below you can see a Software testing guide on How to start unit testing .NET projects.
The unit testing tools needed:
Unit Test framework:
The first tool need is a testing framework. You have a couple of choices there. If you are using Microsoft Visual Studio 2008 Professional or above, you already have the Microsoft unit testing framework installed. The framework comes also with Microsoft Visual Studio 2005 Team System.
You may also decide to go with one of the open source frameworks: NUnit, MbUnit (now part of the Gallio project) or xUnit. There are minor differences between the different frameworks, but the main features are the same. However, the Microsoft one also comes with a built-in test runner. It allows you to run tests inside Visual studio. To achieve the same ease-of-use with the open source frameworks you will need TestDriven.Net by Jamie Cansdale.
For using the attributes and API of the different frameworks, you just need to add references to them in your test project. The Microsoft test framework has a special Test Project, the other framework uses a regular DLL container for the tests.
Mocking Framework:
The next thing you need is a mocking framework, like Isolator. Follow the steps in our quick start guide how to write the first test. You’ll need to add references to Isolator DLLs.
Now for your first test: In order to make it easy, let’s start by testing a component you’re already working on. It’s very important to integrate test writing into your regular work, and that’s the first step.
In your test project, create a test class, called after your class-under-test. For example, if your class is called MyClass, call the test class MyClassTests.
Writing the first unit test:
Now it’s time to write a test. Decide what public method you want to test, what is the specific scenario and the expected result for that scenario. Use that information to name your test. Use the following convention:
public void METHODNAME_SCENARIO_RESULT()
Now add the content of the test. A test contains three parts:
Arrange – setup for the test
Act – the actual invocation of the method
Assert – verification of pass/fail condition for the test
Make sure you use Assert functions to specify pass/failure functionality. You can also use Isolate.Verify for method calls as well, otherwise, the test will appear to have passed.
Run the test. If the test fails, add additional behavior setting statements with Isolator in the Arrange part, to make sure the test follows the specific scenario you’re testing.
Did the test finally pass? Congratulations! You now can move to the next one.
Remember, the more tests you have, you get better coverage, and your code becomes more stable.
Unit Testing Legacy Code Effectively
There are many advantages to unit testing in software development companies. Typemock’s tools help companies to shorten the development cycle, reduce the development costs and release a higher quality, by making unit testing easy to perform. Watch the below Unit testing video tutorial (or webinar) to learn how you can start unit testing the existing projects (legacy code) in your company. In this unit testing tutorial, which is presented by Gil Zilberfeld, Typemock will show the best way to effectively test your legacy code, using Isolator, without redesigning your existing (or legacy) code. This unit testing tutorial includes: To get information on future webinars, make sure to visit our blog. First session:Download this webinar in HQ to your PC Resources
Want a specific video tutorial? Add a resource to the list? Stop by the forums, and let us know! |
Webinar: How To Implement Unit Testing In Your Company And Teams
There are many advantages to unit testing in software development companies. Typemock’s tools help companies to shorten the development cycle, reduce the development costs, increase code coverage and release a higher quality product with fewer bugs. Watch the below Leading Your Company into Unit-Testing State of Mind (or webinar) to get tips for implementing unit testing in your company. In this unit testing tutorial, which is presented by Roy Osherove and Gil Zilberfeld, Typemock will show how you can become a change agent and lead the implementation of unit testing, in your company. Watch this unit testing tutorial to learn how you can make a difference in your company. This video tutorial gives you tools that can assist your workplace in implementing unit testing practices. To get information on future webinars, make sure to visit our blog.
Download this webinar to your PC in HQ
Resources
Want a specific video tutorial? Add a resource to the list? Stop by the forums, and let us know! |