Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Manning.The.Art.of.Unit.Testing.with.Examples.in.dot.NET.Jun.2009.pdf
Скачиваний:
18
Добавлен:
21.03.2016
Размер:
9.67 Mб
Скачать

Thread-related testing

281

it. Instead, I recommend Project White (discussed next) for WinForm testing.

You can get it at http://nunitforms.sourceforge.net/.

B.6.2 Project White

Project White is, in a way, a successor to NUnitForms, in that it supports a richer set of application types (WPF, WinForm, Win32, and Java JWT), and sports a newer API with better usability. Unlike NUnitForms, White is more of an integration-test framework, because it allows spawning separate processes that it tests against.

White uses the UIAutomation API (part of Windows) to do its bidding, which gives it much more power. You can think of it as Selenium or WatiN for WinForms.

You can get White at http://www.codeplex.com/white.

B.6.3 Team System UI Tests

The upcoming version of Visual Studio Team System will support a new kind of test—a UI test. You’ll be able to record actions on UI windows and play them back and verify assertions during test runs. As with all Team System tools, its main advantage will be its integration with other Team System tools, reports, source control, and servers.

You can learn more about Team System at http://msdn.microsoft.com/ en-us/teamsystem/default.aspx.

B.7 Thread-related testing

Threads have always been the bane of unit testing. They’re simply untestable. That’s why new frameworks are emerging that let you test threadrelated logic (deadlocks, race conditions, and so on), such as these:

Typemock Racer

Microsoft CHESS

Osherove.ThreadTester

I’ll give a brief rundown of each tool.

282

APPENDIX B

Extra tools and frameworks

B.7.1 Typemock Racer

Typemock Racer is a managed framework for multithreaded code testing that helps visualize, detect, and resolve deadlocks and race conditions in managed code. You use it by putting an attribute on top of an existing test method, and the engine does all the work. It also allows full thread visualization during debugging of a threaded test.

NOTE Full disclosure: during the writing of this book, I’ve been part of the developer team at Typemock.

Racer is a commercial product that works with all flavors of Visual Studio (including Express) and all test frameworks. You can get it at www.Typemock.com.

B.7.2 Microsoft CHESS

CHESS is an upcoming tool that will be offered by Microsoft with Visual Studio 2010. (It’s currently offered only as part of MS Research.) Much like Typemock Racer, CHESS attempts to find thread-related problems (deadlocks, hangs, livelocks, and more) in your code by running all relevant permutations of threads on existing code. These tests are written as simple unit tests.

CHESS currently supports native code, but a managed .NET version should be coming out soon as part of Visual Studio Team System (a commercial product).

You can get CHESS at

http://research.microsoft.com/projects/CHESS/.

B.7.3 Osherove.ThreadTester

This is a little open source framework I developed a while back. It allows you to run multiple threads during one test to see if anything weird happens to your code (deadlocks, for example). It isn’t featurecomplete, but it’s a good attempt at a multithreaded test (rather than a test for multithreaded code).

You can get it from my blog, at http://weblogs.asp.net/rosherove/ archive/2007/06/22/multi-threaded-unit-tests-with-osherove-thread- tester.aspx.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]