[1146] | 1 | SampleSuiteExtension Example
|
---|
| 2 |
|
---|
| 3 | This is a minimal example of a SuiteBuilder extension. It extends
|
---|
| 4 | NUnit.Core.TestSuite test suite and creates a fixture that runs every
|
---|
| 5 | test starting with "SampleTest..." It packages both the core extension
|
---|
| 6 | and the attribute used in the tests in the same assembly.
|
---|
| 7 |
|
---|
| 8 | SampleSuiteExtension Class
|
---|
| 9 |
|
---|
| 10 | This class derives from NUnit.Framework.TestSuite and represents the
|
---|
| 11 | extended suite within NUnit. Because it inherits from TestSuite,
|
---|
| 12 | rather than TestFixture, it has to construct its own fixture object and
|
---|
| 13 | find its own tests. Everything is done in the constructor for simplicity.
|
---|
| 14 |
|
---|
| 15 | SampleSuiteExtensionBuilder
|
---|
| 16 |
|
---|
| 17 | This class is the actual SuiteBuilder loaded by NUnit as an add-in.
|
---|
| 18 | It recognizes the SampleSuiteExtensionAttribute and invokes the
|
---|
| 19 | SampleSuiteExtension constructor to build the suite.
|
---|
| 20 |
|
---|
| 21 | SampleSuiteExtensionAttribute
|
---|
| 22 |
|
---|
| 23 | This is the special attribute used to mark tests to be constructed
|
---|
| 24 | using this add-in. It is the only class referenced from the user tests.
|
---|
| 25 |
|
---|
| 26 | Note on Building this Extension
|
---|
| 27 |
|
---|
| 28 | If you use the Visual Studio solution, the NUnit references in both
|
---|
| 29 | included projects must be changed so that they refer to the copy of
|
---|
| 30 | NUnit in which you want to install the extension. The post-build step
|
---|
| 31 | for the SampleSuiteExtension project must be changed to copy the
|
---|
| 32 | extension into the addins directory for your NUnit install.
|
---|
| 33 |
|
---|
| 34 | NOTE:
|
---|
| 35 |
|
---|
| 36 | The references to nunit.core and nunit.common in the
|
---|
| 37 | SampleSuiteExtension project have their Copy Local property set to
|
---|
| 38 | false, rather than the Visual Studio default of true. In developing
|
---|
| 39 | extensions, it is essential there be no extra copies of these assemblies
|
---|
| 40 | be created. Once the extension is complete, those who install it in
|
---|
| 41 | binary form will not need to deal with this issue.
|
---|
| 42 |
|
---|
| 43 |
|
---|