How to write a driver test using a Driver Test template
Note
This topic describes functionality that is only available in Visual Studio 2013. For info on previous WDK and Visual Studio editions, see Other WDK downloads.
You can use the Windows Driver Kit (WDK) for Windows 8 to create your own driver tests or to customize some of the tests that are provided. You can deploy the tests that you create to remote test computers using the driver testing framework that the WDK provides for Microsoft Visual Studio Ultimate 2012.
The WDK provides templates that create starter code for a Windows Driver test project in C++, C#, and Script (JScript). You can select the test cases that you want to include, or you can start with a blank project. You can customize the code to add new test cases for your driver. You can deploy your tests from Visual Studio using the driver test framework.
To customize a driver test using the Driver Test template for C++
- From the File menu, select New > Project.
- From the list of installed templates in the New Project dialog box, select Visual C++ > Windows Driver > Tests.
- Select Windows Driver Test in C++.
- Provide a name for your driver test project and a location (or use the default).
- From the Windows Driver Test dialog box, select the test cases that you want to include or choose an empty (blank) driver test. For more information about the test cases, see Windows Driver test cases.
- Add the required test metadata. For more information, see How to add test metadata.
- Build your driver test.
To customize a driver test using the Driver Test template for C#
- From the File menu, select New > Project.
- From the list of installed templates in the New Project dialog box, select Visual C# > Windows Driver .
- Select Windows Driver Test in C#.
- Provide a name for your driver test project and a location (or use the default).
- From the Windows Driver Test dialog box, select the test cases that you want to include or choose an empty (blank) driver test. For information about the test cases, see Windows Driver test cases.
- Add the required test metadata. For more information, see How to add test metadata.
- Build your driver test.
To customize a driver test using the Driver Test template for Script
- From the File menu, select New > Project.
- From the list of installed templates in the New Project dialog box, select Script > Windows Driver .
- Select Windows Driver Test Script.
- Provide a name for your driver test project and a location (or use the default).
- From the Windows Driver Test dialog box, select the test cases that you want to include or choose an empty (blank) driver test. For information about the test cases, see Windows Driver test cases.
- Add the required test metadata. For more information, see How to add test metadata.
- Build your driver test.
Making the driver tests you create available for deployment on test computers
When you build your driver test, the new test will be available for deployment to a test computer. By default, the tests that you create will appear in the test category My Test Category. The names of the tests are based upon the test cases that you choose, and they will have names such as My Plug and Play Surprise Remove Test. During each build of the test, the test will be overwritten. The latest build of the test will be available to deploy and run on the test computer.
Windows Driver test cases
The WDK provides starter code for a Windows Driver test project in C++, C#, and Script. You can select test cases that you want to include, or you can start with a blank project. Not all test cases are available in every language.
Plug and Play Test Cases | Test cases that force a driver to handle most of the Plug and Play (PnP)-related IRPs |
---|---|
Disable/Enable | Provides code for test cases that disable and enable a PnP device. |
Remove | Provides code for test cases that remove a PnP device. |
Surprise Remove | Provides code for test cases that perform a surprise remove of a PnP device. |
Power Management Test Cases | Provides test cases that force a driver to handle system sleep states. |
System Sleep States | Provides code for test cases that perform device I/O while the system cycles through sleep and power state. |
Stress and Functionality Test Cases | Provides test cases that perform I/O stress and function testing of IOCTL and WMI interfaces. |
I/O Stress | Provides test cases that perform device I/O stress. |
Functional IOCTL Interface | Provides a template for creating functional test cases for the IOCTL interface. (only available for C++ ). |
Functional WMI Interface | Provides a template for creating functional test cases for the Windows Management Interface (WMI). (only available in Script) |
Empty Test Case | |
Provides a blank template for creating a Windows Driver test project. |