background preloader

Unit Testing XNA

Facebook Twitter

Visual Studio 2010: Test Driven Development. Description Visual Studio 2010 brings with it several enhancements to help cut development friction and enable the developer to focus on the task at hand: writing high-quality code.

Visual Studio 2010: Test Driven Development

In the following exercises we'll highlight several of the new features that the TDD developer can use to enhance his/her development cadence. Visual Studio helps your cadence by cutting the number of keystrokes to accomplish frequently performed tasks, speeds navigation through your solution, and enables you to use test frameworks other than MSTest. Overview Test Driven Development (TDD), also frequently referred to as Test Driven Design, is a development methodology where developers create software by first writing a unit test, then writing the actual system code to make the unit test pass.

TDD follows a cadence of “Red, Green, Refactor.” Note: This lab is not meant to teach you how to work with TDD; instead, it is intended to highlight Visual Studio 2010’s support for working in TDD. Objectives Setup Exercises. Unit testing does not work with XNA 4.0. Unit Testing Games (Part 1) – Vectors and Transformations « Milan Nankov’s Blog. Test driven development and testing in general are mandatory techniques if you are serious about the code that you create.

Unit Testing Games (Part 1) – Vectors and Transformations « Milan Nankov’s Blog

That is especially true in game development where almost every piece of code is very complex. In this first post about testing I will give you a little insight about testing vectors and transformations. The code that I am going to provide is written for the XNA framework and the Visual Studio testing framework but the concepts that are described in this post can be applied to any game development and testing platforms. In many cases ensuring that a vector is the one we expect is not as straight forward as writing: Assert.AreEqual(expectedVector, actualVector). Assert.AreEqual(expectedVector, actualVector). To illustrate the problem imagine that we have a vector (0, 0, -200), we perform some operations that transform the vector by rotating it around the Y axis by 90 degrees, and we want to assert that the operation is done correctly. Happy testing. Scurvy Test. Unit testing - Xna: Mocking Texture2D. Test-Driven Development. It’s one thing to see someone drive a car and have a theoretical understanding of what the pedals do and how to change gears.

Test-Driven Development

It’s is a completely different thing to be able to drive a car safely on the street. There are some activities that require many small details and some hands-on experience to be able to execute them successfully. The good news is that unit testing is a lot simpler than driving a standard shift, but there are a lot of small details you need to get right to do it successfully. Even after reading about unit testing and being convinced of its benefits, programmers are often not sure how to get started. This month’s column is not going to try to convince you of the many benefits of unit testing (I hope you are already convinced), but rather, describe some very concrete tips to help you get started right away. Goals of Unit Testing There are many different reasons to write unit tests: Correctness testing. When working with unit tests, these are our main goals: Hello Tests.