Merge files from nunit-console
This commit is contained in:
Коммит
9ab0f90278
|
@ -16,4 +16,9 @@ build
|
|||
obj
|
||||
package
|
||||
deploy
|
||||
<<<<<<< HEAD:.gitignore
|
||||
test-results
|
||||
=======
|
||||
lib
|
||||
|
||||
>>>>>>> nunit-console/master:.gitignore
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
Building NUnit 3.0
|
||||
|
||||
NUnit 3.0 consists of three separate layers: the Framework, the Engine and the Console Runner. There is a Visual Studio solution and a NAnt build script for each of these. Eventually, the three layers will be independent projects. For now, they are developed in a single repository and have some dependencies.
|
||||
|
||||
The solutions all place their output in a common bin directory. In order to satisfy all references you must first build the framework, then the engine and finally the console runner.
|
||||
|
||||
For the time being, there is also a combined solutions and a combined script, making it easier to work on the overall initial development of NUnit 3.0.
|
||||
|
||||
The following guidelines are provided for developers working on NUnit:
|
||||
|
||||
1. When working on changes to the Framework alone, use the NUnitFramework solution and/or NAnt script. Examples of such changes might be new constraints and new or modified attributes. This is probably the most common sort of change that you will need to make.
|
||||
|
||||
2. NUnitLite is built as a part of the framework layer and makes no use of the engine or console layers. Consequently, changes to NUnitLite must also be made at this level.
|
||||
|
||||
3. When working on changes to the Engine alone, use the NUnitEngine solution and/or NAnt script. An example of such a change would be to support an additional framework or to run tests on a remote system. Such changes should be somewhat rare once the Engine is released.
|
||||
|
||||
4. When working on changes to the Console Runner alone, use the NUnitConsole solution and/or NAnt script. Changes to the report output produced by the runner would be an example of such a change.
|
||||
|
||||
5. When changes involve multiple levels, it is recommended that you develop
|
||||
and test the individual pieces using the single-component solutions or scripts and then use the combined solution or script to ensure that it all works together.
|
||||
|
||||
Further guidelines are given below for each layer and for the combined solution/scripts.
|
||||
|
||||
Framework Layer
|
||||
|
||||
The NUnitFramework build produces the following assemblies:
|
||||
* nunit.framework.dll - the framework itself
|
||||
* nunit.framework.tests.dll - tests of the framework
|
||||
* nunit.testdata.dll - data used by the tests
|
||||
* nunitlite.dll - the NUnitLite framework
|
||||
* nunitlite.tests.dll - tests of the NUnitLite framework
|
||||
* nunitlite.testdata.dll - data used by the NUnitLite tests
|
||||
* direct-runner.exe - test harness used to run framework tests
|
||||
* mock-assembly.dll - a test assembly used by some of the tests
|
||||
Each of these is built for three targets: .NET 2.0, .NET 3.5 and .NET 4.0. Features requiring either .NET 3.5 or .NET 4.0 are excluded from lesser builds by the use of conditional tests.
|
||||
|
||||
The NUnitFramework solution builds each of the assemblies for each target for a total of 24 assemblies. The output assemblies for each target are stored in a separate subdirectory under the shared bin directory used by all of the solutions.
|
||||
|
||||
The NAnt build for each target stores its output in separate subdirectories of the NUnitFramework/build directory. The 'deploy' target copies the output to a higher level shared directory for use in combined tests. The 'deploy-test' target runs tests in the deploy directory.
|
||||
|
||||
Whenever changes are made, it's important to run all tests and to ensure that both the solutions and the nant scripts are updated as needed. The NAnt test
|
||||
target runs tests for both full NUnit and NUnitLite. When using the solutions, it is necessary to run them separately to ensure that everything is working.
|
||||
|
||||
Engine Layer
|
||||
|
||||
The Engine build produces the following assemblies:
|
||||
* nunit.engine.dll - the engine itself
|
||||
* nunit.engine.api.dll - the api assembly referenced by runners
|
||||
* nunit-agent.exe - the agent used for running tests in a separate process
|
||||
* nunit.engine.tests.dll - tests of the engine
|
||||
Engine components are all built with a target of .NET 2.0.
|
||||
|
||||
The NUnitEngine solution builds all the engine assemblies. It produces output in the shared bin directory and references the .NET 2.0 builds of nunit.framework.dll and mock-assembly.dll. In addition, the 2.0 build of direct-runner.exe is copied to the bin directory in order to run the tests.
|
||||
|
||||
The NAnt build script puts the engine assemblies into the NUnitEngine/build directory. The 'deploy' target copies the output to the higher level deploy directory. The 'deploy-test' target runs tests in the deploy directory.
|
||||
|
||||
Console Layer
|
||||
|
||||
The Console Runner build produces the following assemblies:
|
||||
* nunit-console.exe
|
||||
* nunit-console.tests.dll
|
||||
All assemblies are built with a target of .NET 2.0.
|
||||
|
||||
The NUnitConsole solution produces output in the shared bin directory. The tests reference nunit.framework.dll. The console runner itself is used to execute its own tests.
|
||||
|
||||
The NAnt build script produces output in the NUnitConsole/build directory. The 'deploy' target copies the output to the higner level deploy directory. The 'deploy-test' target runs tests in the deploy directory.
|
||||
|
||||
Combined Solution and Scripts
|
||||
|
||||
The nunit.sln file builds includes all assemblies from the other three solutions with the exception of those related to NUnitLite. The Console runner is used to execute tests in the NUnitTests.nunit project file, which contains separate configs for testing under .NET 2.0, 3.5 and 4.0.
|
||||
|
||||
The master NAnt script, nunit.build, uses the three lower-level scripts to build and deploy the NUnit assemblies and run tests under the console runner.
|
||||
Separate console executions are used to run tests for the Console, the Engine and the Framework. Framework tests are run under each of the supported platforms that is available on the build machine.
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
NUnit 2.9.6 - October 4, 2013
|
||||
|
||||
Main Features
|
||||
* Separate projects for nunit-console and nunit.engine
|
||||
* New builds for .NET 4.5 and Silverlight
|
||||
* TestContext is now supported
|
||||
* External API is now stable; internal interfaces are separate from API
|
||||
* Tests may be run in parallel on separate threads
|
||||
* Solutions and projects now use VS2012 (except for Compact framework)
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 463470 We should encapsulate references to pre-2.0 collections
|
||||
* 498690 Assert.That() doesn't like properties with scoped setters
|
||||
* 501784 Theory tests do not work correctly when using null parameters
|
||||
* 531873 Feature: Extraction of unit tests from NUnit test assembly and calling appropriate one
|
||||
* 611325 Allow Teardown to detect if last test failed
|
||||
* 611938 Generic Test Instances disappear
|
||||
* 655882 Make CategoryAttribute inherited
|
||||
* 664081 Add Server2008 R2 and Windows 7 to PlatformAttribute
|
||||
* 671432 Upgrade NAnt to Latest Release
|
||||
* 676560 Assert.AreEqual does not support IEquatable<T>
|
||||
* 691129 Add Category parameter to TestFixture
|
||||
* 697069 Feature request: dynamic location for TestResult.xml
|
||||
* 708173 NUnit's logic for comparing arrays - use Comparer<T[]> if it is provided
|
||||
* 709062 "System.ArgumentException : Cannot compare" when the element is a list
|
||||
* 712156 Tests cannot use AppDomain.SetPrincipalPolicy
|
||||
* 719184 Platformdependency in src/ClientUtilities/util/Services/DomainManager.cs:40
|
||||
* 719187 Using Path.GetTempPath() causes conflicts in shared temporary folders
|
||||
* 735851 Add detection of 3.0, 3.5 and 4.0 frameworks to PlatformAttribute
|
||||
* 736062 Deadlock when EventListener performs a Trace call + EventPump synchronisation
|
||||
* 756843 Failing assertion does not show non-linear tolerance mode
|
||||
* 766749 net-2.0\nunit-console-x86.exe.config should have a <startup /> element and also enable loadFromRemoteSources
|
||||
* 770471 Assert.IsEmpty does not support IEnumerable
|
||||
* 785460 Add Category parameter to TestCaseSourceAttribute
|
||||
* 787106 EqualConstraint provides inadequate failure information for IEnumerables
|
||||
* 792466 TestContext MethodName
|
||||
* 794115 HashSet incorrectly reported
|
||||
* 800089 Assert.Throws() hides details of inner AssertionException
|
||||
* 848713 Feature request: Add switch for console to break on any test case error
|
||||
* 878376 Add 'Exactly(n)' to the NUnit constraint syntax
|
||||
* 882137 When no tests are run, higher level suites display as Inconclusive
|
||||
* 882517 NUnit 2.5.10 doesn't recognize TestFixture if there are only TestCaseSource inside
|
||||
* 885173 Tests are still executed after cancellation by user
|
||||
* 885277 Exception when project calls for a runtime using only 2 digits
|
||||
* 885604 Feature request: Explicit named parameter to TestCaseAttribute
|
||||
* 890129 DelayedConstraint doesn't appear to poll properties of objects
|
||||
* 892844 Not using Mono 4.0 profile under Windows
|
||||
* 893919 DelayedConstraint fails polling properties on references which are initially null
|
||||
* 896973 Console output lines are run together under Linux
|
||||
* 897289 Is.Empty constraint has unclear failure message
|
||||
* 898192 Feature Request: Is.Negative, Is.Positive
|
||||
* 898256 IEnumerable<T> for Datapoints doesn't work
|
||||
* 899178 Wrong failure message for parameterized tests that expect exceptions
|
||||
* 904841 After exiting for timeout the teardown method is not executed
|
||||
* 908829 TestCase attribute does not play well with variadic test functions
|
||||
* 910218 NUnit should add a trailing separator to the ApplicationBase
|
||||
* 920472 CollectionAssert.IsNotEmpty must dispose Enumerator
|
||||
* 922455 Add Support for Windows 8 and Windows 2012 Server to PlatformAttribute
|
||||
* 928246 Use assembly.Location instead of assembly.CodeBase
|
||||
* 958766 For development work under TeamCity, we need to support nunit2 formatted output under direct-runner
|
||||
* 1000181 Parameterized TestFixture with System.Type as constructor arguments fails
|
||||
* 1000213 Inconclusive message Not in report output
|
||||
* 1023084 Add Enum support to RandomAttribute
|
||||
* 1028188 Add Support for Silverlight
|
||||
* 1029785 Test loaded from remote folder failed to run with exception System.IODirectory
|
||||
* 1037144 Add MonoTouch support to PlatformAttribute
|
||||
* 1041365 Add MaxOsX and Xbox support to platform attribute
|
||||
* 1057981 C#5 async tests are not supported
|
||||
* 1060631 Add .NET 4.5 build
|
||||
* 1064014 Simple async tests should not return Task<T>
|
||||
* 1071164 Support async methods in usage scenarios of Throws constraints
|
||||
* 1071343 Runner.Load fails on CF if the test assembly contains a generic method
|
||||
* 1071861 Error in Path Constraints
|
||||
* 1072379 Report test execution time at a higher resolution
|
||||
* 1074568 Assert/Assume should support an async method for the ActualValueDelegate
|
||||
* 1082330 Better Exception if SetCulture attribute is applied multiple times
|
||||
* 1111834 Expose Random Object as part of the test context
|
||||
* 1111838 Include Random Seed in Test Report
|
||||
* 1172979 Add Category Support to nunitlite Runner
|
||||
* 1203361 Randomizer uniqueness tests sometimes fail
|
||||
* 1221712 When non-existing test method is specified in -test, result is still "Tests run: 1, Passed: 1"
|
||||
* 1223294 System.NullReferenceException thrown when ExpectedExceptionAttribute is used in a static class
|
||||
* 1225542 Standardize commandline options for test harness
|
||||
|
||||
Bug Fixes in 2.9.6 But Not Listed Here in the Release
|
||||
* 541699 Silverlight Support
|
||||
* 1222148 /framework switch does not recognize net-4.5
|
||||
* 1228979 Theories with all test cases inconclusive are not reported as failures
|
||||
|
||||
|
||||
NUnit 2.9.5 - July 30, 2010
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 483836 Allow non-public test fixtures consistently
|
||||
* 487878 Tests in generic class without proper TestFixture attribute should be invalid
|
||||
* 498656 TestCase should show array values in GUI
|
||||
* 513989 Is.Empty should work for directories
|
||||
* 519912 Thread.CurrentPrincipal Set In TestFixtureSetUp Not Maintained Between Tests
|
||||
* 532488 constraints from ConstraintExpression/ConstraintBuilder are not reusable
|
||||
* 590717 categorie contains dash or trail spaces is not selectable
|
||||
* 590970 static TestFixtureSetUp/TestFixtureTearDown methods in base classes are not run
|
||||
* 595683 NUnit console runner fails to load assemblies
|
||||
* 600627 Assertion message formatted poorly by PropertyConstraint
|
||||
* 601108 Duplicate test using abstract test fixtures
|
||||
* 601645 Parametered test should try to convert data type from source to parameter
|
||||
* 605432 ToString not working properly for some properties
|
||||
* 606548 Deprecate Directory Assert in 2.5 and remove it in 3.0
|
||||
* 608875 NUnit Equality Comparer incorrectly defines equality for Dictionary objects
|
||||
|
||||
NUnit 2.9.4 - May 4, 2010
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 419411 Fixture With No Tests Shows as Non-Runnable
|
||||
* 459219 Changes to thread princpal cause failures under .NET 4.0
|
||||
* 459224 Culture test failure under .NET 4.0
|
||||
* 462019 Line endings needs to be better controlled in source
|
||||
* 462418 Assume.That() fails if I specify a message
|
||||
* 483845 TestCase expected return value cannot be null
|
||||
* 488002 Should not report tests in abstract class as invalid
|
||||
* 490679 Category in TestCaseData clashes with Category on ParameterizedMethodSuite
|
||||
* 501352 VS2010 projects have not been updated for new directory structure
|
||||
* 504018 Automatic Values For Theory Test Parameters Not Provided For bool And enum
|
||||
* 505899 'Description' parameter in both TestAttribute and TestCaseAttribute is not allowed
|
||||
* 523335 TestFixtureTearDown in static class not executed
|
||||
* 556971 Datapoint(s)Attribute should work on IEnumerable<T> as well as on Arrays
|
||||
* 561436 SetCulture broken with 2.5.4
|
||||
* 563532 DatapointsAttribute should be allowed on properties and methods
|
||||
|
||||
NUnit 2.9.3 - October 26, 2009
|
||||
|
||||
Main Features
|
||||
|
||||
* Created new API for controlling framework
|
||||
* New builds for .Net 3.5 and 4.0, compact framework 3.5
|
||||
* Support for old style tests has been removed
|
||||
* New adhoc runner for testing the framework
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 432805 Some Framework Tests don't run on Linux
|
||||
* 440109 Full Framework does not support "Contains"
|
||||
|
||||
NUnit 2.9.2 - September 19, 2009
|
||||
|
||||
Main Features
|
||||
|
||||
* NUnitLite code is now merged with NUnit
|
||||
* Added NUnitLite runner to the framework code
|
||||
* Added Compact framework builds
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 430100 Assert.Catch<T> should return T
|
||||
* 432566 NUnitLite shows empty string as argument
|
||||
* 432573 Mono test should be at runtime
|
||||
|
||||
NUnit 2.9.1 - August 27, 2009
|
||||
General
|
||||
|
||||
* Created a separate project for the framework and framework tests
|
||||
* Changed license to MIT / X11
|
||||
* Created Windows installer for the framework
|
||||
|
||||
Bug Fixes
|
||||
|
||||
* 400502 NUnitEqualityComparer.StreamsEqual fails for same stream
|
||||
* 400508 TestCaseSource attirbute is not working when Type is given
|
||||
* 400510 TestCaseData variable length ctor drops values
|
||||
* 417557 Add SetUICultureAttribute from NUnit 2.5.2
|
||||
* 417559 Add Ignore to TestFixture, TestCase and TestCaseData
|
||||
* 417560 Merge Assert.Throws and Assert.Catch changes from NUnit 2.5.2
|
||||
* 417564 TimeoutAttribute on Assembly
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Copyright (c) 2011-2013 Charlie Poole
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,481 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnitConsole" default="build" basedir=".">
|
||||
|
||||
<description>
|
||||
**************************************************************************
|
||||
* This script is used to build the NUnit Console runner and tests. *
|
||||
* *
|
||||
* Dependencies: *
|
||||
* *
|
||||
* Building the runner requires at least .NET 3.5 but it runs under *
|
||||
* .NET 2.0 or greater. *
|
||||
* *
|
||||
* The script requires the NAnt 0.92 release with the config file *
|
||||
* modified in order to run run tests under .NET 4.5. *
|
||||
* *
|
||||
* PartCover is required to run the 'test-coverage' target. *
|
||||
* *
|
||||
**************************************************************************
|
||||
</description>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Common properties that control the build ************** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<!-- Project name - used as a prefix for packages -->
|
||||
<property name="project.name" value="NUnitConsole"/>
|
||||
|
||||
<!-- NUnit Package Version - Three digits -->
|
||||
<property name="package.version" value="2.9.7"/>
|
||||
|
||||
<!-- Package Configuration (Release, Alpha, Beta, etc.) -->
|
||||
<property name="package.configuration" value=""/>
|
||||
|
||||
<!-- Base name for packages - add suffix for Alpha, Beta, RC -->
|
||||
<property name="package.name"
|
||||
value="${project.name}-${package.version}"/>
|
||||
|
||||
<!-- Set default warning level for compiles -->
|
||||
<property name="warn" value="4" unless="${property::exists('warn')}"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Define Project Directories ********* -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<!-- Project base dir is nant project base dir -->
|
||||
<property name="project.base.dir"
|
||||
value="${project::get-base-directory()}"/>
|
||||
|
||||
<!-- Other directories are derived from base dir -->
|
||||
<property name="project.build.dir"
|
||||
value="${path::combine(project.base.dir,'build')}"/>
|
||||
<property name="project.package.dir"
|
||||
value="${path::combine(project.base.dir,'package')}"/>
|
||||
<property name="project.src.dir"
|
||||
value="${path::combine(project.base.dir, 'src')}"/>
|
||||
<property name="project.doc.dir"
|
||||
value="${path::combine(project.base.dir,'doc')}"/>
|
||||
<property name="project.lib.dir"
|
||||
value="${path::combine(project.base.dir,'lib')}"/>
|
||||
<property name="project.tools.dir"
|
||||
value="${path::combine(project.base.dir,'../tools')}"/>
|
||||
<property name="partcover.dir"
|
||||
value="${path::combine(project.tools.dir, 'PartCover')}"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Define Packaging Directories ********* -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<property name="package.working.dir"
|
||||
value="${path::combine(project.package.dir,package.name)}"
|
||||
unless="${property::exists('package.working.dir')}"/>
|
||||
<property name="package.bin.dir"
|
||||
value="${path::combine(package.working.dir,'bin')}"/>
|
||||
<property name="package.doc.dir"
|
||||
value="${path::combine(package.working.dir,'doc')}"/>
|
||||
<property name="package.src.dir"
|
||||
value="${path::combine(package.working.dir,'src')}"/>
|
||||
<property name="package.lib.dir"
|
||||
value="${path::combine(package.working.dir,'lib')}"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Set Default Build Configuration ********* -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<property name="build.config" value="debug"
|
||||
unless="${property::exists('build.config')}"/>
|
||||
<call target="set-${build.config}-build-config"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** The Engine targets .NET 2.0 but must be built using 3.5. *** -->
|
||||
<!-- *** For now, we use .NET by preference if it's available. . *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<property name="can.build.net"
|
||||
value="${framework::exists('net-3.5') and framework::sdk-exists('net-3.5')}"/>
|
||||
|
||||
<property name="can.build.mono"
|
||||
value="${framework::exists('mono-3.5') and framework::sdk-exists('mono-3.5')}"/>
|
||||
|
||||
<fail message="Either the net-3.5 or mono-3.5 runtime is required to build nunit-console"
|
||||
unless="${can.build.net or can.build.mono}" />
|
||||
|
||||
<property name="nant.settings.currentframework" value= "net-3.5"
|
||||
if="${can.build.net}" />
|
||||
|
||||
<property name="nant.settings.currentframework" value= "mono-3.5"
|
||||
unless="${can.build.net}" />
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Location of the NUnitFramework project, If Present *** -->
|
||||
<!-- *** Override in local.settings.include) *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<property name="framework.project.dir"
|
||||
value="${path::combine(project.base.dir, '../NUnitFramework')}"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Constants used for running tests ************ -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<!-- Allow setting options at the NAnt command line -->
|
||||
<property name="nunit.options" value=""
|
||||
unless="${property::exists('nunit.options')}"/>
|
||||
<property name="nunit.console.program"
|
||||
value="nunit-console.exe"/>
|
||||
<property name="nunit.console.args"
|
||||
value="nunit-console.tests.dll nunit.engine.tests.dll -config:${build.config} ${nunit.options}"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- In the optional local.settings.include file, installations may -->
|
||||
<!-- set properties to override the location of external tools, -->
|
||||
<!-- the nunit framework assembly, directories, etc. -->
|
||||
<!-- -->
|
||||
<!-- Copy and edit local.settings.include.template if needed -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<include buildfile="local.settings.include" failonerror="false"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Targets that set the build configuration *** -->
|
||||
<!-- *** These must come before actions like build or test *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="debug" depends="set-debug-build-config"
|
||||
description="Set config to debug for commands that follow"/>
|
||||
|
||||
<target name="release" depends="set-release-build-config"
|
||||
description="Set config to release for commands that follow"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Targets that clean directories *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="clean-all"
|
||||
description="Removes both Debug and Release build output">
|
||||
|
||||
<delete dir="${project.build.dir}"
|
||||
if="${directory::exists( project.build.dir )}"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="clean"
|
||||
description="Removes output for the current build">
|
||||
|
||||
<delete dir="${current.build.dir}"
|
||||
if="${directory::exists( current.build.dir )}"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="clean-package-dir">
|
||||
|
||||
<delete dir="${package.working.dir}"
|
||||
if="${directory::exists( package.working.dir )}"/>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Build the Console Runner *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="build"
|
||||
description="Build nunit-console">
|
||||
|
||||
<mkdir dir="${current.build.dir}"
|
||||
unless="${directory::exists(current.build.dir)}"/>
|
||||
|
||||
<call target="update-lib-dir"
|
||||
if="${property::exists('auto.update.lib.dir') and auto.update.lib.dir}"/>
|
||||
|
||||
<copy todir="${current.build.dir}">
|
||||
<fileset basedir="${project.lib.dir}">
|
||||
<include name="*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<nant target="build">
|
||||
<buildfiles refid="console.buildfiles" failonerror="true" />
|
||||
</nant>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- Update framework directories from the last .NET 2.0 or Mono 2.0
|
||||
release build. Note that this looks at builds done with NAnt,
|
||||
not Visual Studio. -->
|
||||
<target name="update-lib-dir"
|
||||
description="Update lib dir with latest framework build">
|
||||
|
||||
<property name="runtime" value="net-2.0" if="${can.build.net}"/>
|
||||
<property name="runtime" value="mono-2.0" unless="${can.build.net}"/>
|
||||
|
||||
<if test="${property::exists('framework.project.dir')}">
|
||||
<if test="${directory::exists(framework.project.dir)}">
|
||||
<copy todir="${project.lib.dir}">
|
||||
<fileset basedir="${framework.project.dir}/bin/Release/${runtime}">
|
||||
<include name="nunit.framework.dll"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</if>
|
||||
</if>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Run Tests *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="test" depends="build,run-test"
|
||||
description="Build and run tests for selected config and runtime"/>
|
||||
|
||||
<target name="run-test">
|
||||
|
||||
<echo message="*"/>
|
||||
<echo message="* Testing the nunit-console ${build.config} build"/>
|
||||
<echo message="*"/>
|
||||
|
||||
<!--<property name="nant.settings.currentframework" value="net-2.0"/>-->
|
||||
|
||||
<exec basedir="${current.build.dir}"
|
||||
workingdir="${current.build.dir}"
|
||||
program="${nunit.console.program}"
|
||||
managed="Auto"
|
||||
commandline="${nunit.console.args}" />
|
||||
|
||||
</target>
|
||||
|
||||
<target name="test-coverage" depends="build,run-coverage"
|
||||
description="Run tests under PartCover to get coverage results"/>
|
||||
|
||||
<target name="run-coverage">
|
||||
|
||||
<echo message="*"/>
|
||||
<echo message="* Starting the NUnitConsole ${build.config} test coverage run"/>
|
||||
<echo message="*"/>
|
||||
|
||||
<!--<property name="nant.settings.currentframework" value="net-2.0"/>-->
|
||||
|
||||
<exec basedir="${partcover.dir}"
|
||||
workingdir="${current.build.dir}"
|
||||
program="PartCover.exe">
|
||||
|
||||
<arg line='--target "${nunit.console.program}"' />
|
||||
<arg line='--target-args "${nunit.console.args}"' />
|
||||
<arg line='--include [nunit-console]NUnit.*' />
|
||||
<arg line='--output TestCoverage.xml' />
|
||||
|
||||
</exec>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Create All Packages for Distribution *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="package-all"
|
||||
depends="package-src,package-docs,package"
|
||||
description="Create standard packages for distribution"/>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Create Binary Package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="package"
|
||||
description="Create a binary package for the current build">
|
||||
|
||||
<call target="clean-package-dir"/>
|
||||
<call target="copy-license" />
|
||||
<call target="copy-bins" />
|
||||
<call target="copy-docs" />
|
||||
|
||||
<zip ziplevel="9"
|
||||
zipfile="${project.package.dir}/${package.name}${build.suffix}.zip">
|
||||
<fileset basedir="${package.working.dir}" prefix="${package.name}">
|
||||
<include name="**"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Package Source Files *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="package-src"
|
||||
description="Create full source package for developer use">
|
||||
|
||||
<call target="clean-package-dir"/>
|
||||
<call target="copy-license" />
|
||||
<call target="copy-docs"/>
|
||||
<call target="copy-src"/>
|
||||
<call target="copy-libs"/>
|
||||
|
||||
<zip ziplevel="9"
|
||||
zipfile="${project.package.dir}/${package.name}-src.zip">
|
||||
<fileset basedir="${package.working.dir}" prefix="${package.name}">
|
||||
<include name="**"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Package docs *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="package-docs"
|
||||
description="Create a zip of the docs only">
|
||||
<!--
|
||||
<call target="clean-package-dir"/>
|
||||
<call target="copy-license"/>
|
||||
<call target="copy-docs"/>
|
||||
|
||||
<zip ziplevel="9"
|
||||
zipfile="${project.package.dir}/${package.name}-docs.zip">
|
||||
<fileset basedir="${package.working.dir}" prefix="${package.name}">
|
||||
<include name="**"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
-->
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Helper targets used for packaging *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Copy License and Notices for a package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="copy-license">
|
||||
|
||||
<copy todir="${package.working.dir}">
|
||||
<fileset>
|
||||
<include name="LICENSE.txt"/>
|
||||
<include name="NOTICES.txt"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Copy a set of binaries for a package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="copy-bins" depends="build">
|
||||
|
||||
<mkdir dir="${package.bin.dir}"/>
|
||||
<copy todir="${package.bin.dir}">
|
||||
<fileset basedir="${current.build.dir}">
|
||||
<include name="nunit-console.*" />
|
||||
<include name="nunit.framework.dll" />
|
||||
<include name="nunit.engine.api.dll" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Copy the documentation for a package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="copy-docs">
|
||||
<mkdir dir="${package.doc.dir}"/>
|
||||
<copy todir="${package.doc.dir}">
|
||||
<fileset basedir="${project.doc.dir}">
|
||||
<include name="*.html"/>
|
||||
<include name="nunit.css"/>
|
||||
<include name="codeFuncs.js"/>
|
||||
<include name="favicon.ico"/>
|
||||
<include name="files/*"/>
|
||||
<include name="img/*"/>
|
||||
<exclude name="img/thumbs.db"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Copy the source code for a package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="copy-src">
|
||||
<delete dir="${package.src.dir}" />
|
||||
<mkdir dir="${package.src.dir}"/>
|
||||
|
||||
<copy todir="${package.working.dir}">
|
||||
<fileset basedir="${project.base.dir}">
|
||||
<include name="LICENSE.txt"/>
|
||||
<include name="NOTICES.txt"/>
|
||||
<include name="*.build"/>
|
||||
<include name="nunit.snk"/>
|
||||
<include name="nant"/>
|
||||
<include name="nant.bat"/>
|
||||
<include name="CommonAssemblyInfo.cs"/>
|
||||
<include name="*.sln"/>
|
||||
<include name="lib/*"/>
|
||||
<include name="local.settings.include.sample"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
<nant target="package">
|
||||
<buildfiles refid="console.buildfiles" failonerror="true" />
|
||||
</nant>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- *** Copy the libraries for a source package *** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="copy-libs">
|
||||
|
||||
<mkdir dir="${package.lib.dir}"/>
|
||||
<copy todir="${package.lib.dir}">
|
||||
<fileset basedir="${project.lib.dir}">
|
||||
<include name="*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Targets for setting the build configuration *********** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<target name="set-debug-build-config">
|
||||
|
||||
<property name="build.config" value="debug"/>
|
||||
<property name="current.build.dir" value="${project.build.dir}/debug"/>
|
||||
<property name="build.debug" value="true"/>
|
||||
<property name="build.defines" value="DEBUG,TRACE"
|
||||
dynamic="true"/>
|
||||
<property name="build.suffix" value="-dbg"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="set-release-build-config">
|
||||
|
||||
<property name="build.config" value="release"/>
|
||||
<property name="current.build.dir" value="${project.build.dir}/release"/>
|
||||
<property name="build.debug" value="false"/>
|
||||
<property name="build.defines" value="TRACE"
|
||||
dynamic="true"/>
|
||||
<property name="build.suffix" value=""/>
|
||||
|
||||
</target>
|
||||
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- ********* Lower Level Buildfiles *********** -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<fileset id="console.buildfiles">
|
||||
|
||||
<include name="src/mock-assembly/mock-assembly.build" />
|
||||
<include name="src/nunit.engine.api/nunit.engine.api.build" />
|
||||
<include name="src/nunit.engine/nunit.engine.build" />
|
||||
<include name="src/nunit.engine.tests/nunit.engine.tests.build" />
|
||||
<include name="src/nunit-agent/nunit-agent.build" />
|
||||
<include name="src/nunit-console/nunit-console.build" />
|
||||
<include name="src/nunit-console.tests/nunit-console.tests.build" />
|
||||
|
||||
</fileset>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,65 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-console", "src\nunit-console\nunit-console.csproj", "{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-console.tests", "src\nunit-console.tests\nunit-console.tests.csproj", "{B310A760-8AE1-41CA-81F8-03B12E2FCE30}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.engine.api", "src\nunit.engine.api\nunit.engine.api.csproj", "{775FAD50-3623-4922-97C4-DFB29A8BE4C7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.engine", "src\nunit.engine\nunit.engine.csproj", "{372A3447-D657-40FF-A089-77C19FEC30C8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit.engine.tests", "src\nunit.engine.tests\nunit.engine.tests.csproj", "{D694CB69-6CFB-4762-86C2-EB27B808B282}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nunit-agent", "src\nunit-agent\nunit-agent.csproj", "{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{147554FB-464E-4E4D-ADD6-B84121AAE2A5}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
local.settings.include.sample = local.settings.include.sample
|
||||
NUnitConsole.build = NUnitConsole.build
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mock-assembly", "src\mock-assembly\mock-assembly.csproj", "{2E368281-3BA8-4050-B05E-0E0E43F8F446}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B310A760-8AE1-41CA-81F8-03B12E2FCE30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B310A760-8AE1-41CA-81F8-03B12E2FCE30}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B310A760-8AE1-41CA-81F8-03B12E2FCE30}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B310A760-8AE1-41CA-81F8-03B12E2FCE30}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{775FAD50-3623-4922-97C4-DFB29A8BE4C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{775FAD50-3623-4922-97C4-DFB29A8BE4C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{775FAD50-3623-4922-97C4-DFB29A8BE4C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{775FAD50-3623-4922-97C4-DFB29A8BE4C7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{372A3447-D657-40FF-A089-77C19FEC30C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{372A3447-D657-40FF-A089-77C19FEC30C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{372A3447-D657-40FF-A089-77C19FEC30C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{372A3447-D657-40FF-A089-77C19FEC30C8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D694CB69-6CFB-4762-86C2-EB27B808B282}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D694CB69-6CFB-4762-86C2-EB27B808B282}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D694CB69-6CFB-4762-86C2-EB27B808B282}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D694CB69-6CFB-4762-86C2-EB27B808B282}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2E368281-3BA8-4050-B05E-0E0E43F8F446}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2E368281-3BA8-4050-B05E-0E0E43F8F446}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2E368281-3BA8-4050-B05E-0E0E43F8F446}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2E368281-3BA8-4050-B05E-0E0E43F8F446}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = NUnitConsole\src\nunit-console\nunit-console-vs2010.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,165 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeEditing/GenerateMemberBody/CopyXmlDocumentation/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantThisQualifier/@EntryIndexedValue">SUGGESTION</s:String>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_LINQ_QUERY/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_FOR_STMT/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTIPLE_DECLARATION/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTLINE_TYPE_PARAMETER_LIST/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AROUND_MULTIPLICATIVE_OP/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/@EntryValue">False</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/FileHeader/FileHeaderText/@EntryValue">***********************************************************************
|
||||
Copyright (c) $CURRENT_YEAR$ Charlie Poole
|
||||

|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||

|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||

|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
***********************************************************************
|
||||
</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue"><Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb"><ExtraRule Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=USER/Expression/@EntryValue">getUserName()</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=USER/InitialRange/@EntryValue">-1</s:Int64>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=YEAR/Expression/@EntryValue">getCurrentDate("yyyy")</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=YEAR/InitialRange/@EntryValue">-1</s:Int64>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Shortcut/@EntryValue">copyright</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Description/@EntryValue">NUnit Copyright</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Text/@EntryValue">// ***********************************************************************
|
||||
// Copyright (c) $YEAR$ $USER$
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
// 
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
// 
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Reformat/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/ShortenQualifiedReferences/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Scope/=558F05AA0DE96347816FF785232CFB2A/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Scope/=558F05AA0DE96347816FF785232CFB2A/Type/@EntryValue">InCSharpTypeAndNamespace</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Scope/=558F05AA0DE96347816FF785232CFB2A/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=YEAR/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=YEAR/Order/@EntryValue">0</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=USER/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=1256596694514F41A4D79DB082E50E51/Field/=USER/Order/@EntryValue">1</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Description/@EntryValue">Test Method</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Field/=TEST_005FMETHOD/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Field/=TEST_005FMETHOD/Expression/@EntryValue">constant("TestMethod")</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Field/=TEST_005FMETHOD/Order/@EntryValue">0</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Reformat/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/Type/@EntryValue">InCSharpTypeMember</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Shortcut/@EntryValue">test</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/ShortenQualifiedReferences/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=6ACED16A1977164DBEC1AABF77ECAE5F/Text/@EntryValue">[Test]
|
||||
public void $TEST_METHOD$()
|
||||
{
|
||||
$END$
|
||||
}</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Applicability/=Live/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Description/@EntryValue">Test Fixture</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FCLASS/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FCLASS/Expression/@EntryValue">constant("TestClass")</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FCLASS/Order/@EntryValue">0</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FMETHOD/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FMETHOD/Expression/@EntryValue">constant("TestMethod")</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Field/=TEST_005FMETHOD/Order/@EntryValue">1</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Reformat/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=558F05AA0DE96347816FF785232CFB2A/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=558F05AA0DE96347816FF785232CFB2A/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=558F05AA0DE96347816FF785232CFB2A/Type/@EntryValue">InCSharpTypeAndNamespace</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/CustomProperties/=minimumLanguageVersion/@EntryIndexedValue">2.0</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Scope/=B68999B9D6B43E47A02B22C12A54C3CC/Type/@EntryValue">InCSharpTypeMember</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Shortcut/@EntryValue">tf</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/ShortenQualifiedReferences/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=73F8A8FB97CC7A40BB04F4ACB4DC6D06/Text/@EntryValue">[TestFixture]
|
||||
public class $TEST_CLASS$
|
||||
{
|
||||
[Test]
|
||||
public void $TEST_METHOD$()
|
||||
{
|
||||
$END$
|
||||
}
|
||||
}</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Applicability/=File/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/CustomProperties/=Extension/@EntryIndexedValue">cs</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/CustomProperties/=FileName/@EntryIndexedValue">TestClass</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/CustomProperties/=ValidateFileName/@EntryIndexedValue">True</s:String>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Description/@EntryValue">&Test Class</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=CLASS/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=CLASS/Expression/@EntryValue">getFileNameWithoutExtension()</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=CLASS/InitialRange/@EntryValue">-1</s:Int64>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=CLASS/Order/@EntryValue">2</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=HEADER/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=HEADER/Expression/@EntryValue">fileheader()</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=HEADER/InitialRange/@EntryValue">-1</s:Int64>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=HEADER/Order/@EntryValue">0</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=NAMESPACE/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=NAMESPACE/Expression/@EntryValue">fileDefaultNamespace()</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=NAMESPACE/InitialRange/@EntryValue">-1</s:Int64>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=NAMESPACE/Order/@EntryValue">1</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=TEST_005FMETHOD/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=TEST_005FMETHOD/Expression/@EntryValue">constant("TestMethod")</s:String>
|
||||
<s:Int64 x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Field/=TEST_005FMETHOD/Order/@EntryValue">3</s:Int64>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Reformat/@EntryValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Scope/=E8F0594528C33E45BBFEC6CFE851095D/@KeyIndexDefined">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Scope/=E8F0594528C33E45BBFEC6CFE851095D/Type/@EntryValue">InCSharpProjectFile</s:String>
|
||||
<s:Boolean x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/ShortenQualifiedReferences/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/PatternsAndTemplates/LiveTemplates/Template/=8DB051565EE336439784EE0FE0DE0FB7/Text/@EntryValue">$HEADER$
|
||||
#region Using Directives
|
||||

|
||||
using System;
|
||||
using NUnit.Framework;
|
||||

|
||||
#endregion
|
||||

|
||||
namespace $NAMESPACE$
|
||||
{
|
||||
[TestFixture]
|
||||
public class $CLASS$ 
|
||||
{
|
||||
[Test]
|
||||
public void $TEST_METHOD$()
|
||||
{
|
||||
$END$
|
||||
}
|
||||
}
|
||||
}</s:String></wpf:ResourceDictionary>
|
|
@ -0,0 +1,11 @@
|
|||
<NUnitProject>
|
||||
<Settings/>
|
||||
<Config name="Debug">
|
||||
<assembly path="bin/debug/nunit-console.tests.dll" />
|
||||
<assembly path="bin/debug/nunit.engine.tests.dll" />
|
||||
</Config>
|
||||
<Config name="Release">
|
||||
<assembly path="bin/release/nunit-console.tests.dll" />
|
||||
<assembly path="bin/release/nunit.engine.tests.dll" />
|
||||
</Config>
|
||||
</NUnitProject>
|
Двоичный файл не отображается.
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnitConsole" default="build" basedir=".">
|
||||
<!-- ***************************************************************** -->
|
||||
<!-- In the optional local.settings.include file, installations may -->
|
||||
<!-- set properties to override the location of external tools, -->
|
||||
<!-- the nunit framework assembly, directories, etc. -->
|
||||
<!-- -->
|
||||
<!-- Do not modify this template when you add local settings, since -->
|
||||
<!-- it is stored in our source code repository and used by all devs. -->
|
||||
<!-- Instead, copy this file to 'local.settings.include' and make -->
|
||||
<!-- changes as needed for your installation. -->
|
||||
<!-- -->
|
||||
<!-- In addition to the properties shown, you may change any that are -->
|
||||
<!-- set in the NUnitConsole.build file before this file is included, -->
|
||||
<!-- so long as your changes are consistent. -->
|
||||
<!-- ***************************************************************** -->
|
||||
|
||||
<!-- Location of the Tools directory. -->
|
||||
<property name="project.tools.dir"
|
||||
value="${path::combine(project.base.dir, '../tools'}"/>
|
||||
|
||||
<!-- Location of the NUnitFramework project, if present. -->
|
||||
<!-- This property must have a valid value set in order to use -->
|
||||
<!-- the update-lib-dir target. -->
|
||||
<property name="framework.project.dir"
|
||||
value="${path::combine(project.base.dir, '../NUnitFramework'}"/>
|
||||
|
||||
<!-- Uncomment the following line to automatically update the -->
|
||||
<!-- framework assemblies in the lib directory before each build. -->
|
||||
<!-- This can be convenient if you need to switch back and forth -->
|
||||
<!-- frequently between the framework and console projects. -->
|
||||
<!-- -->
|
||||
<!-- WARNING: You should not be doing this in most cases. It is -->
|
||||
<!-- usually best to get a feature working in the framework first -->
|
||||
<!-- and only then add code needed to access it from the console. -->
|
||||
<!--<property name ="auto.update.lib.dir" value="true"/>-->
|
||||
</project>
|
|
@ -0,0 +1,39 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
//
|
||||
// Common Information about the NUnit Engine and Console assemblies
|
||||
//
|
||||
[assembly: AssemblyCompany("NUnit Software")]
|
||||
[assembly: AssemblyProduct("NUnit 3.0")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2014 Charlie Poole")]
|
||||
[assembly: AssemblyTrademark("NUnit is a trademark of NUnit Software")]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: AssemblyConfiguration("Debug")]
|
||||
#else
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
#endif
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
//
|
||||
// Common Versioning for the NUnit Engine and Console assemblies
|
||||
//
|
||||
[assembly: AssemblyVersion("3.0.*")]
|
|
@ -0,0 +1,17 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Mock Assembly")]
|
||||
[assembly: AssemblyDescription("Test assembly used by NUnit tests")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("37f4a88d-9f41-462e-ac05-93f1d390b700")]
|
|
@ -0,0 +1,309 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
|
||||
namespace NUnit.Engine.Tests
|
||||
{
|
||||
namespace Assemblies
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant definitions for the mock-assembly dll.
|
||||
/// </summary>
|
||||
public class MockAssembly
|
||||
{
|
||||
public static int Classes = 9;
|
||||
public static int NamespaceSuites = 6; // assembly, NUnit, Tests, Assemblies, Singletons, TestAssembly
|
||||
|
||||
public static int Tests = MockTestFixture.Tests
|
||||
+ Singletons.OneTestCase.Tests
|
||||
+ TestAssembly.MockTestFixture.Tests
|
||||
+ IgnoredFixture.Tests
|
||||
+ ExplicitFixture.Tests
|
||||
+ BadFixture.Tests
|
||||
+ FixtureWithTestCases.Tests
|
||||
+ ParameterizedFixture.Tests
|
||||
+ GenericFixtureConstants.Tests;
|
||||
|
||||
public static int Suites = MockTestFixture.Suites
|
||||
+ Singletons.OneTestCase.Suites
|
||||
+ TestAssembly.MockTestFixture.Suites
|
||||
+ IgnoredFixture.Suites
|
||||
+ ExplicitFixture.Suites
|
||||
+ BadFixture.Suites
|
||||
+ FixtureWithTestCases.Suites
|
||||
+ ParameterizedFixture.Suites
|
||||
+ GenericFixtureConstants.Suites
|
||||
+ NamespaceSuites;
|
||||
|
||||
public static readonly int Nodes = Tests + Suites;
|
||||
|
||||
public static int ExplicitFixtures = 1;
|
||||
public static int SuitesRun = Suites - ExplicitFixtures;
|
||||
|
||||
public static int Ignored = MockTestFixture.Ignored + IgnoredFixture.Tests;
|
||||
public static int Explicit = MockTestFixture.Explicit + ExplicitFixture.Tests;
|
||||
public static int NotRunnable = MockTestFixture.NotRunnable + BadFixture.Tests;
|
||||
public static int NotRun = Ignored + Explicit + NotRunnable;
|
||||
public static int TestsRun = Tests - NotRun;
|
||||
public static int ResultCount = Tests - Explicit;
|
||||
|
||||
public static int Errors = MockTestFixture.Errors;
|
||||
public static int Failures = MockTestFixture.Failures;
|
||||
public static int ErrorsAndFailures = Errors + Failures;
|
||||
public static int Inconclusive = MockTestFixture.Inconclusive;
|
||||
public static int Success = TestsRun - ErrorsAndFailures - Inconclusive;
|
||||
|
||||
public static int Categories = MockTestFixture.Categories;
|
||||
|
||||
public static string AssemblyPath = AssemblyHelper.GetAssemblyPath(typeof(MockAssembly).Assembly);
|
||||
}
|
||||
|
||||
public class MockSuite
|
||||
{
|
||||
[Suite]
|
||||
public static TestSuite Suite
|
||||
{
|
||||
get
|
||||
{
|
||||
return new TestSuite( "MockSuite" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture(Description="Fake Test Fixture")]
|
||||
[Category("FixtureCategory")]
|
||||
public class MockTestFixture
|
||||
{
|
||||
public static readonly int Tests = 11;
|
||||
public static readonly int Suites = 1;
|
||||
|
||||
public static readonly int Ignored = 1;
|
||||
public static readonly int Explicit = 1;
|
||||
public static readonly int NotRunnable = 2;
|
||||
public static readonly int NotRun = Ignored + Explicit + NotRunnable;
|
||||
public static readonly int TestsRun = Tests - NotRun;
|
||||
public static readonly int ResultCount = Tests - Explicit;
|
||||
|
||||
public static readonly int Failures = 1;
|
||||
public static readonly int Errors = 1;
|
||||
public static readonly int ErrorsAndFailures = Errors + Failures;
|
||||
public const int Inconclusive = 1;
|
||||
|
||||
public static readonly int Categories = 5;
|
||||
public static readonly int MockCategoryTests = 2;
|
||||
|
||||
[Test(Description="Mock Test #1")]
|
||||
public void MockTest1()
|
||||
{}
|
||||
|
||||
[Test]
|
||||
[Category("MockCategory")]
|
||||
[Property("Severity","Critical")]
|
||||
[Description("This is a really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really, really long description")]
|
||||
public void MockTest2()
|
||||
{}
|
||||
|
||||
[Test]
|
||||
[Category("MockCategory")]
|
||||
[Category("AnotherCategory")]
|
||||
public void MockTest3()
|
||||
{ Assert.Pass("Succeeded!"); }
|
||||
|
||||
[Test]
|
||||
protected static void MockTest5()
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void FailingTest()
|
||||
{
|
||||
Assert.Fail("Intentional failure");
|
||||
}
|
||||
|
||||
[Test, Property("TargetMethod", "SomeClassName"), Property("Size", 5), /*Property("TargetType", typeof( System.Threading.Thread ))*/]
|
||||
public void TestWithManyProperties()
|
||||
{}
|
||||
|
||||
[Test]
|
||||
[Ignore("ignoring this test method for now")]
|
||||
[Category("Foo")]
|
||||
public void MockTest4()
|
||||
{}
|
||||
|
||||
[Test, Explicit]
|
||||
[Category( "Special" )]
|
||||
public void ExplicitlyRunTest()
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void NotRunnableTest( int a, int b)
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InconclusiveTest()
|
||||
{
|
||||
Assert.Inconclusive("No valid data");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestWithException()
|
||||
{
|
||||
MethodThrowsException();
|
||||
}
|
||||
|
||||
private void MethodThrowsException()
|
||||
{
|
||||
throw new Exception("Intentional Exception");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Singletons
|
||||
{
|
||||
[TestFixture]
|
||||
public class OneTestCase
|
||||
{
|
||||
public static readonly int Tests = 1;
|
||||
public static readonly int Suites = 1;
|
||||
|
||||
[Test]
|
||||
public virtual void TestCase()
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
namespace TestAssembly
|
||||
{
|
||||
[TestFixture]
|
||||
public class MockTestFixture
|
||||
{
|
||||
public static readonly int Tests = 1;
|
||||
public static readonly int Suites = 1;
|
||||
|
||||
[Test]
|
||||
public void MyTest()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture, Ignore]
|
||||
public class IgnoredFixture
|
||||
{
|
||||
public static readonly int Tests = 3;
|
||||
public static readonly int Suites = 1;
|
||||
|
||||
[Test]
|
||||
public void Test1() { }
|
||||
|
||||
[Test]
|
||||
public void Test2() { }
|
||||
|
||||
[Test]
|
||||
public void Test3() { }
|
||||
}
|
||||
|
||||
[TestFixture,Explicit]
|
||||
public class ExplicitFixture
|
||||
{
|
||||
public static readonly int Tests = 2;
|
||||
public static readonly int Suites = 1;
|
||||
public static readonly int Nodes = Tests + Suites;
|
||||
|
||||
[Test]
|
||||
public void Test1() { }
|
||||
|
||||
[Test]
|
||||
public void Test2() { }
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class BadFixture
|
||||
{
|
||||
public static readonly int Tests = 1;
|
||||
public static readonly int Suites = 1;
|
||||
|
||||
public BadFixture(int val) { }
|
||||
|
||||
[Test]
|
||||
public void SomeTest() { }
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class FixtureWithTestCases
|
||||
{
|
||||
public static readonly int Tests = 4;
|
||||
public static readonly int Suites = 3;
|
||||
|
||||
[TestCase(2, 2, ExpectedResult=4)]
|
||||
[TestCase(9, 11, ExpectedResult=20)]
|
||||
public int MethodWithParameters(int x, int y)
|
||||
{
|
||||
return x+y;
|
||||
}
|
||||
|
||||
[TestCase(2, 4)]
|
||||
[TestCase(9.2, 11.7)]
|
||||
public void GenericMethod<T>(T x, T y)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture(5)]
|
||||
[TestFixture(42)]
|
||||
public class ParameterizedFixture
|
||||
{
|
||||
public static readonly int Tests = 4;
|
||||
public static readonly int Suites = 3;
|
||||
|
||||
public ParameterizedFixture(int num) { }
|
||||
|
||||
[Test]
|
||||
public void Test1() { }
|
||||
|
||||
[Test]
|
||||
public void Test2() { }
|
||||
}
|
||||
|
||||
public class GenericFixtureConstants
|
||||
{
|
||||
public static readonly int Tests = 4;
|
||||
public static readonly int Suites = 3;
|
||||
}
|
||||
|
||||
[TestFixture(5)]
|
||||
[TestFixture(11.5)]
|
||||
public class GenericFixture<T>
|
||||
{
|
||||
public GenericFixture(T num){ }
|
||||
|
||||
[Test]
|
||||
public void Test1() { }
|
||||
|
||||
[Test]
|
||||
public void Test2() { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="MockAssembly" default="build" basedir=".">
|
||||
|
||||
<target name="build">
|
||||
<csc target="library"
|
||||
output="${current.build.dir}/mock-assembly.dll"
|
||||
debug="${build.debug}" define="${build.defines}"
|
||||
warninglevel="${warn}">
|
||||
<sources>
|
||||
<include name="*.cs"/>
|
||||
</sources>
|
||||
<references basedir="${current.build.dir}">
|
||||
<include name="nunit.framework.dll"/>
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
<copy todir="${package.src.dir}/mock-assembly">
|
||||
<fileset>
|
||||
<include name="*.cs"/>
|
||||
<include name="*.csproj"/>
|
||||
<include name="mock-assembly.build"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,95 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{2E368281-3BA8-4050-B05E-0E0E43F8F446}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>mock-assembly</AssemblyName>
|
||||
<DefaultClientScript>JScript</DefaultClientScript>
|
||||
<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>
|
||||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>NUnit.Engine.Tests</RootNamespace>
|
||||
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>false</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>full</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>..\..\bin\Release\net-2.0\</OutputPath>
|
||||
<BaseAddress>285212672</BaseAddress>
|
||||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>true</Optimize>
|
||||
<RegisterForComInterop>false</RegisterForComInterop>
|
||||
<RemoveIntegerChecks>false</RemoveIntegerChecks>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DebugType>none</DebugType>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System">
|
||||
<Name>System</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Data">
|
||||
<Name>System.Data</Name>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml">
|
||||
<Name>System.XML</Name>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\CommonVersionInfo.cs">
|
||||
<Link>CommonVersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="MockAssembly.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="mock-assembly.build" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -0,0 +1,17 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NUnit Agent")]
|
||||
[assembly: AssemblyDescription("Runs tests in a separate process when necessary")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("59b4d53d-99d7-44f2-8c6e-b83d41718dd6")]
|
|
@ -0,0 +1,168 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2008 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Channels.Tcp;
|
||||
using System.Diagnostics;
|
||||
using NUnit.Engine;
|
||||
using NUnit.Engine.Agents;
|
||||
using NUnit.Engine.Internal;
|
||||
using NUnit.Engine.Services;
|
||||
|
||||
namespace NUnit.Agent
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Program.
|
||||
/// </summary>
|
||||
public class NUnitTestAgent
|
||||
{
|
||||
//static Logger log = InternalTrace.GetLogger(typeof(NUnitTestAgent));
|
||||
|
||||
static Guid AgentId;
|
||||
static string AgencyUrl;
|
||||
static ITestAgency Agency;
|
||||
|
||||
/// <summary>
|
||||
/// Channel used for communications with the agency
|
||||
/// and with clients
|
||||
/// </summary>
|
||||
static TcpChannel Channel;
|
||||
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
AgentId = new Guid(args[0]);
|
||||
AgencyUrl = args[1];
|
||||
|
||||
bool pause = false, verbose = false;
|
||||
for (int i = 2; i < args.Length; i++)
|
||||
switch (args[i])
|
||||
{
|
||||
case "--pause":
|
||||
pause = true;
|
||||
break;
|
||||
case "--verbose":
|
||||
verbose = true;
|
||||
break;
|
||||
}
|
||||
#if DEBUG
|
||||
if (pause)
|
||||
System.Windows.Forms.MessageBox.Show("Attach debugger if desired, then press OK", "NUnit-Agent");
|
||||
#endif
|
||||
|
||||
// Create SettingsService early so we know the trace level right at the start
|
||||
SettingsService settingsService = new SettingsService("NUnit30Settings.xml", false);
|
||||
//InternalTrace.Initialize("nunit-agent_%p.log", (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default));
|
||||
|
||||
//log.Info("Agent process {0} starting", Process.GetCurrentProcess().Id);
|
||||
//log.Info("Running under version {0}, {1}",
|
||||
// Environment.Version,
|
||||
// RuntimeFramework.CurrentFramework.DisplayName);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Console.WriteLine("Agent process {0} starting", Process.GetCurrentProcess().Id);
|
||||
Console.WriteLine("Running under version {0}, {1}",
|
||||
Environment.Version,
|
||||
RuntimeFramework.CurrentFramework.DisplayName);
|
||||
}
|
||||
|
||||
// Create TestEngine - this program is
|
||||
// conceptually part of the engine and
|
||||
// can access it's internals as needed.
|
||||
TestEngine engine = new TestEngine();
|
||||
|
||||
// Custom Service Initialization
|
||||
//log.Info("Adding Services");
|
||||
engine.Services.Add(settingsService);
|
||||
engine.Services.Add(new ProjectService());
|
||||
engine.Services.Add(new DomainManager());
|
||||
engine.Services.Add(new InProcessTestRunnerFactory());
|
||||
engine.Services.Add(new DriverFactory());
|
||||
//engine.Services.Add( new TestLoader() );
|
||||
|
||||
// Initialize Services
|
||||
//log.Info("Initializing Services");
|
||||
engine.Services.ServiceManager.InitializeServices();
|
||||
|
||||
Channel = ServerUtilities.GetTcpChannel();
|
||||
|
||||
//log.Info("Connecting to TestAgency at {0}", AgencyUrl);
|
||||
try
|
||||
{
|
||||
Agency = Activator.GetObject(typeof(ITestAgency), AgencyUrl) as ITestAgency;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Unable to connect\r\n{0}", ex);
|
||||
//log.Error("Unable to connect", ex);
|
||||
}
|
||||
|
||||
if (Channel != null)
|
||||
{
|
||||
//log.Info("Starting RemoteTestAgent");
|
||||
RemoteTestAgent agent = new RemoteTestAgent(AgentId, Agency, engine.Services);
|
||||
|
||||
try
|
||||
{
|
||||
if (agent.Start())
|
||||
{
|
||||
//log.Debug("Waiting for stopSignal");
|
||||
agent.WaitForStop();
|
||||
//log.Debug("Stop signal received");
|
||||
}
|
||||
else
|
||||
Console.WriteLine("Failed to start RemoteTestAgent");
|
||||
//log.Error("Failed to start RemoteTestAgent");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//log.Error("Exception in RemoteTestAgent", ex);
|
||||
Console.WriteLine("Exception in RemoteTestAgent", ex);
|
||||
}
|
||||
|
||||
//log.Info("Unregistering Channel");
|
||||
try
|
||||
{
|
||||
ChannelServices.UnregisterChannel(Channel);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//log.Error("ChannelServices.UnregisterChannel threw an exception", ex);
|
||||
Console.WriteLine("ChannelServices.UnregisterChannel threw an exception\r\n{0}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
Console.WriteLine("Agent process {0} exiting", Process.GetCurrentProcess().Id);
|
||||
//log.Info("Agent process {0} exiting", Process.GetCurrentProcess().Id);
|
||||
//InternalTrace.Close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<!--
|
||||
Nunit-agent only runs under .NET 2.0 or higher.
|
||||
The setting useLegacyV2RuntimeActivationPolicy only applies
|
||||
under .NET 4.0 and permits use of mixed mode assemblies,
|
||||
which would otherwise not load correctly.
|
||||
-->
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<!--
|
||||
Nunit-agent is normally run by the console or gui
|
||||
runners and not independently. In normal usage,
|
||||
the runner specifies which runtime should be used.
|
||||
|
||||
Do NOT add any supportedRuntime elements here,
|
||||
since they may prevent the runner from controlling
|
||||
the runtime that is used!
|
||||
-->
|
||||
</startup>
|
||||
|
||||
<runtime>
|
||||
<!-- Ensure that test exceptions don't crash NUnit -->
|
||||
<legacyUnhandledExceptionPolicy enabled="1" />
|
||||
|
||||
<!-- Run partial trust V2 assemblies in full trust under .NET 4.0 -->
|
||||
<loadFromRemoteSources enabled="true" />
|
||||
|
||||
<!-- Look for addins in the addins directory for now -->
|
||||
<!--<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="lib;addins"/>
|
||||
</assemblyBinding>-->
|
||||
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnitAgent" default="build" basedir=".">
|
||||
|
||||
<patternset id="source-files">
|
||||
<include name="*.cs" />
|
||||
</patternset>
|
||||
|
||||
<target name="build">
|
||||
|
||||
<csc target="exe"
|
||||
output="${current.build.dir}/nunit-agent.exe"
|
||||
debug="${build.debug}"
|
||||
define="${build.defines}"
|
||||
warninglevel="${warn}">
|
||||
<sources basedir=".">
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
<patternset refid="source-files" />
|
||||
</sources>
|
||||
<references basedir="${current.build.dir}">
|
||||
<include name="System.Runtime.Remoting.dll" />
|
||||
<include name="System.Windows.Forms.dll" />
|
||||
<include name="nunit.engine.dll" />
|
||||
<include name="nunit.engine.api.dll" />
|
||||
</references>
|
||||
</csc>
|
||||
|
||||
<copy file="app.config"
|
||||
tofile="${current.build.dir}/nunit-agent.exe.config"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
|
||||
<copy todir="${package.src.dir}/nunit-agent">
|
||||
<fileset>
|
||||
<patternset refid="source-files" />
|
||||
<include name="*.build" />
|
||||
<include name="*.csproj" />
|
||||
<include name="app.config" />
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,75 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{C2A8FC7A-FA64-46EA-AF6D-73D6B371DBF8}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>nunit_agent</RootNamespace>
|
||||
<AssemblyName>nunit-agent</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Runtime.Remoting" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\CommonVersionInfo.cs">
|
||||
<Link>CommonVersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="nunit-agent.build" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\nunit.engine.api\nunit.engine.api.csproj">
|
||||
<Project>{775FAD50-3623-4922-97C4-DFB29A8BE4C7}</Project>
|
||||
<Name>nunit.engine.api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\nunit.engine\nunit.engine.csproj">
|
||||
<Project>{372A3447-D657-40FF-A089-77C19FEC30C8}</Project>
|
||||
<Name>nunit.engine</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,77 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
using Utilities;
|
||||
|
||||
[TestFixture]
|
||||
public class ColorConsoleTests
|
||||
{
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
ColorConsole.Enabled = true;
|
||||
|
||||
// Set to an unknown, unlikely color so that we can test for change
|
||||
Console.ForegroundColor = ConsoleColor.Magenta;
|
||||
|
||||
if( Console.ForegroundColor != ConsoleColor.Magenta )
|
||||
{
|
||||
Assert.Inconclusive("Color tests are inconclusive because the current console does not support color");
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestConstructor()
|
||||
{
|
||||
ConsoleColor expected = ColorConsole.GetColor( ColorStyle.Error );
|
||||
using ( new ColorConsole( ColorStyle.Error ) )
|
||||
{
|
||||
Assert.That(Console.ForegroundColor, Is.EqualTo(expected));
|
||||
}
|
||||
Assert.That( Console.ForegroundColor, Is.Not.EqualTo(expected) );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNoColorOption()
|
||||
{
|
||||
ColorConsole.Enabled = false;
|
||||
|
||||
using (new ColorConsole(ColorStyle.Error))
|
||||
{
|
||||
Assert.That(Console.ForegroundColor, Is.EqualTo(ConsoleColor.Magenta));
|
||||
}
|
||||
Assert.That(Console.ForegroundColor, Is.EqualTo(ConsoleColor.Magenta));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ColorStyleTests
|
||||
{
|
||||
[TestCase(ColorStyle.Pass, ConsoleColor.Green)]
|
||||
[TestCase(ColorStyle.Failure, ConsoleColor.Red)]
|
||||
[TestCase(ColorStyle.Warning, ConsoleColor.Yellow)]
|
||||
[TestCase(ColorStyle.Error, ConsoleColor.Red)]
|
||||
public void TestGetColor( ColorStyle style, ConsoleColor expected )
|
||||
{
|
||||
Assert.That(ColorConsole.GetColor(style), Is.EqualTo(expected));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,471 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using NUnit.Engine;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
using Options;
|
||||
|
||||
[TestFixture]
|
||||
public class CommandLineTests
|
||||
{
|
||||
#region General Tests
|
||||
|
||||
[Test]
|
||||
public void NoInputFiles()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions();
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(0, options.InputFiles.Count);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void AllowForwardSlashDefaultsCorrectly()
|
||||
//{
|
||||
// ConsoleOptions options = new ConsoleOptions();
|
||||
// Assert.AreEqual( Path.DirectorySeparatorChar != '/', options.AllowForwardSlash );
|
||||
//}
|
||||
|
||||
[TestCase("ShowHelp", "help|h")]
|
||||
[TestCase("StopOnError", "stoponerror")]
|
||||
[TestCase("WaitBeforeExit", "wait")]
|
||||
[TestCase("PauseBeforeRun", "pause")]
|
||||
[TestCase("NoHeader", "noheader|noh")]
|
||||
public void CanRecognizeBooleanOptions(string propertyName, string pattern)
|
||||
{
|
||||
Console.WriteLine("Testing " + propertyName);
|
||||
string[] prototypes = pattern.Split('|');
|
||||
|
||||
PropertyInfo property = GetPropertyInfo(propertyName);
|
||||
Assert.AreEqual(typeof(bool), property.PropertyType, "Property '{0}' is wrong type", propertyName);
|
||||
|
||||
foreach (string option in prototypes)
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("-" + option);
|
||||
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option);
|
||||
|
||||
options = new ConsoleOptions("-" + option + "+");
|
||||
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "+");
|
||||
|
||||
options = new ConsoleOptions("-" + option + "-");
|
||||
Assert.AreEqual(false, (bool)property.GetValue(options, null), "Didn't recognize -" + option + "-");
|
||||
|
||||
options = new ConsoleOptions("--" + option);
|
||||
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize --" + option);
|
||||
|
||||
options = new ConsoleOptions("/" + option);
|
||||
Assert.AreEqual(true, (bool)property.GetValue(options, null), "Didn't recognize /" + option);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("Include", "include", new string[] { "Short,Fast" }, new string[0])]
|
||||
[TestCase("Exclude", "exclude", new string[] { "Long" }, new string[0])]
|
||||
[TestCase("ActiveConfig", "config", new string[] { "Debug" }, new string[0])]
|
||||
[TestCase("ProcessModel", "process", new string[] { "Single", "Separate", "Multiple" }, new string[] { "JUNK" })]
|
||||
[TestCase("DomainUsage", "domain", new string[] { "None", "Single", "Multiple" }, new string[] { "JUNK" })]
|
||||
[TestCase("Framework", "framework", new string[] { "net-4.0" }, new string[0])]
|
||||
[TestCase("OutFile", "output|out", new string[] { "output.txt" }, new string[0])]
|
||||
[TestCase("ErrFile", "err", new string[] { "error.txt" }, new string[0])]
|
||||
[TestCase("WorkDirectory", "work", new string[] { "results" }, new string[0])]
|
||||
[TestCase("DisplayTestLabels", "labels", new string[] { "Off", "On", "All" }, new string[] { "JUNK" })]
|
||||
[TestCase("InternalTraceLevel", "trace", new string[] { "Off", "Error", "Warning", "Info", "Debug", "Verbose" }, new string[] { "JUNK" })]
|
||||
public void CanRecognizeStringOptions(string propertyName, string pattern, string[] goodValues, string[] badValues)
|
||||
{
|
||||
string[] prototypes = pattern.Split('|');
|
||||
|
||||
PropertyInfo property = GetPropertyInfo(propertyName);
|
||||
Assert.AreEqual(typeof(string), property.PropertyType);
|
||||
|
||||
foreach (string option in prototypes)
|
||||
{
|
||||
foreach (string value in goodValues)
|
||||
{
|
||||
string optionPlusValue = string.Format("--{0}:{1}", option, value);
|
||||
ConsoleOptions options = new ConsoleOptions(optionPlusValue);
|
||||
Assert.True(options.Validate(), "Should be valid: " + optionPlusValue);
|
||||
Assert.AreEqual(value, (string)property.GetValue(options, null), "Didn't recognize " + optionPlusValue);
|
||||
}
|
||||
|
||||
foreach (string value in badValues)
|
||||
{
|
||||
string optionPlusValue = string.Format("--{0}:{1}", option, value);
|
||||
ConsoleOptions options = new ConsoleOptions(optionPlusValue);
|
||||
Assert.False(options.Validate(), "Should not be valid: " + optionPlusValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase("DefaultTimeout", "timeout")]
|
||||
[TestCase("RandomSeed", "seed")]
|
||||
[TestCase("NumWorkers", "workers")]
|
||||
public void CanRecognizeIntOptions(string propertyName, string pattern)
|
||||
{
|
||||
string[] prototypes = pattern.Split('|');
|
||||
|
||||
PropertyInfo property = GetPropertyInfo(propertyName);
|
||||
Assert.AreEqual(typeof(int), property.PropertyType);
|
||||
|
||||
foreach (string option in prototypes)
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("--" + option + ":42");
|
||||
Assert.AreEqual(42, (int)property.GetValue(options, null), "Didn't recognize --" + option + ":text");
|
||||
}
|
||||
}
|
||||
|
||||
//[TestCase("InternalTraceLevel", "trace", typeof(InternalTraceLevel))]
|
||||
//public void CanRecognizeEnumOptions(string propertyName, string pattern, Type enumType)
|
||||
//{
|
||||
// string[] prototypes = pattern.Split('|');
|
||||
|
||||
// PropertyInfo property = GetPropertyInfo(propertyName);
|
||||
// Assert.IsNotNull(property, "Property {0} not found", propertyName);
|
||||
// Assert.IsTrue(property.PropertyType.IsEnum, "Property {0} is not an enum", propertyName);
|
||||
// Assert.AreEqual(enumType, property.PropertyType);
|
||||
|
||||
// foreach (string option in prototypes)
|
||||
// {
|
||||
// foreach (string name in Enum.GetNames(enumType))
|
||||
// {
|
||||
// {
|
||||
// ConsoleOptions options = new ConsoleOptions("--" + option + ":" + name);
|
||||
// Assert.AreEqual(name, property.GetValue(options, null).ToString(), "Didn't recognize -" + option + ":" + name);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
[TestCase("--include")]
|
||||
[TestCase("--exclude")]
|
||||
[TestCase("--config")]
|
||||
[TestCase("--process")]
|
||||
[TestCase("--domain")]
|
||||
[TestCase("--framework")]
|
||||
[TestCase("--timeout")]
|
||||
//[TestCase("--xml")]
|
||||
[TestCase("--output")]
|
||||
[TestCase("--err")]
|
||||
[TestCase("--work")]
|
||||
[TestCase("--trace")]
|
||||
public void MissingValuesAreReported(string option)
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions(option + "=");
|
||||
Assert.False(options.Validate(), "Missing value should not be valid");
|
||||
Assert.AreEqual("Missing required value for option '" + option + "'.", options.ErrorMessages[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssemblyName()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("nunit.tests.dll");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count);
|
||||
Assert.AreEqual("nunit.tests.dll", options.InputFiles[0]);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void FixtureNamePlusAssemblyIsValid()
|
||||
//{
|
||||
// ConsoleOptions options = new ConsoleOptions( "-fixture:NUnit.Tests.AllTests", "nunit.tests.dll" );
|
||||
// Assert.AreEqual("nunit.tests.dll", options.Parameters[0]);
|
||||
// Assert.AreEqual("NUnit.Tests.AllTests", options.fixture);
|
||||
// Assert.IsTrue(options.Validate());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void AssemblyAloneIsValid()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("nunit.tests.dll");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(0, options.ErrorMessages.Count, "command line should be valid");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InvalidOption()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("-asembly:nunit.tests.dll");
|
||||
Assert.False(options.Validate());
|
||||
Assert.AreEqual(1, options.ErrorMessages.Count);
|
||||
Assert.AreEqual("Invalid argument: -asembly:nunit.tests.dll", options.ErrorMessages[0]);
|
||||
}
|
||||
|
||||
|
||||
//[Test]
|
||||
//public void NoFixtureNameProvided()
|
||||
//{
|
||||
// ConsoleOptions options = new ConsoleOptions( "-fixture:", "nunit.tests.dll" );
|
||||
// Assert.IsFalse(options.Validate());
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void InvalidCommandLineParms()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("-garbage:TestFixture", "-assembly:Tests.dll");
|
||||
Assert.False(options.Validate());
|
||||
Assert.AreEqual(2, options.ErrorMessages.Count);
|
||||
Assert.AreEqual("Invalid argument: -garbage:TestFixture", options.ErrorMessages[0]);
|
||||
Assert.AreEqual("Invalid argument: -assembly:Tests.dll", options.ErrorMessages[1]);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Timeout Option
|
||||
|
||||
[Test]
|
||||
public void TimeoutIsMinusOneIfNoOptionIsProvided()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(-1, options.DefaultTimeout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TimeoutThrowsExceptionIfOptionHasNoValue()
|
||||
{
|
||||
Assert.Throws<Mono.Options.OptionException>(() => new ConsoleOptions("tests.dll", "-timeout"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TimeoutParsesIntValueCorrectly()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-timeout:5000");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(5000, options.DefaultTimeout);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TimeoutCausesErrorIfValueIsNotInteger()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-timeout:abc");
|
||||
Assert.False(options.Validate());
|
||||
Assert.AreEqual(-1, options.DefaultTimeout);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EngineResult Option
|
||||
|
||||
[Test]
|
||||
public void ResultOptionWithFilePath()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
|
||||
OutputSpecification spec = options.ResultOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("nunit3", spec.Format);
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultOptionWithFilePathAndFormat()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml;format=nunit2");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
|
||||
OutputSpecification spec = options.ResultOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("nunit2", spec.Format);
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultOptionWithFilePathAndTransform()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml;transform=transform.xslt");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
|
||||
OutputSpecification spec = options.ResultOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("user", spec.Format);
|
||||
Assert.AreEqual("transform.xslt", spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FileNameWithoutResultOptionLooksLikeParameter()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "results.xml");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(0, options.ErrorMessages.Count);
|
||||
Assert.AreEqual(2, options.InputFiles.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultOptionWithoutFileNameIsInvalid()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:");
|
||||
Assert.False(options.Validate(), "Should not be valid");
|
||||
Assert.AreEqual(1, options.ErrorMessages.Count, "An error was expected");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ResultOptionMayBeRepeated()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-result:results.xml", "-result:nunit2results.xml;format=nunit2", "-result:myresult.xml;transform=mytransform.xslt");
|
||||
Assert.True(options.Validate(), "Should be valid");
|
||||
|
||||
var specs = options.ResultOutputSpecifications;
|
||||
Assert.AreEqual(3, specs.Count);
|
||||
|
||||
var spec1 = specs[0];
|
||||
Assert.AreEqual("results.xml", spec1.OutputPath);
|
||||
Assert.AreEqual("nunit3", spec1.Format);
|
||||
Assert.Null(spec1.Transform);
|
||||
|
||||
var spec2 = specs[1];
|
||||
Assert.AreEqual("nunit2results.xml", spec2.OutputPath);
|
||||
Assert.AreEqual("nunit2", spec2.Format);
|
||||
Assert.Null(spec2.Transform);
|
||||
|
||||
var spec3 = specs[2];
|
||||
Assert.AreEqual("myresult.xml", spec3.OutputPath);
|
||||
Assert.AreEqual("user", spec3.Format);
|
||||
Assert.AreEqual("mytransform.xslt", spec3.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DefaultResultSpecification()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll");
|
||||
Assert.AreEqual(1, options.ResultOutputSpecifications.Count);
|
||||
|
||||
var spec = options.ResultOutputSpecifications[0];
|
||||
Assert.AreEqual("TestResult.xml", spec.OutputPath);
|
||||
Assert.AreEqual("nunit3", spec.Format);
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NoResultSuppressesDefaultResultSpecification()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "-noresult");
|
||||
Assert.AreEqual(0, options.ResultOutputSpecifications.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NoResultSuppressesAllResultSpecifications()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "-result:results.xml", "-noresult", "-result:nunit2results.xml;format=nunit2");
|
||||
Assert.AreEqual(0, options.ResultOutputSpecifications.Count);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Explore Option
|
||||
|
||||
[Test]
|
||||
public void ExploreOptionWithoutPath()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore");
|
||||
Assert.True(options.Validate());
|
||||
Assert.True(options.Explore);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreOptionWithFilePath()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore:results.xml");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
Assert.True(options.Explore);
|
||||
|
||||
OutputSpecification spec = options.ExploreOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("nunit3", spec.Format);
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreOptionWithFilePathAndFormat()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore:results.xml;format=cases");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
Assert.True(options.Explore);
|
||||
|
||||
OutputSpecification spec = options.ExploreOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("cases", spec.Format);
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreOptionWithFilePathAndTransform()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore:results.xml;transform=myreport.xslt");
|
||||
Assert.True(options.Validate());
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
Assert.True(options.Explore);
|
||||
|
||||
OutputSpecification spec = options.ExploreOutputSpecifications[0];
|
||||
Assert.AreEqual("results.xml", spec.OutputPath);
|
||||
Assert.AreEqual("user", spec.Format);
|
||||
Assert.AreEqual("myreport.xslt", spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreOptionWithFilePathUsingEqualSign()
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions("tests.dll", "-explore=C:/nunit/tests/bin/Debug/console-test.xml");
|
||||
Assert.True(options.Validate());
|
||||
Assert.True(options.Explore);
|
||||
Assert.AreEqual(1, options.InputFiles.Count, "assembly should be set");
|
||||
Assert.AreEqual("tests.dll", options.InputFiles[0]);
|
||||
Assert.AreEqual("C:/nunit/tests/bin/Debug/console-test.xml", options.ExploreOutputSpecifications[0].OutputPath);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private static FieldInfo GetFieldInfo(string fieldName)
|
||||
{
|
||||
FieldInfo field = typeof(ConsoleOptions).GetField(fieldName);
|
||||
Assert.IsNotNull(field, "The field '{0}' is not defined", fieldName);
|
||||
return field;
|
||||
}
|
||||
|
||||
private static PropertyInfo GetPropertyInfo(string propertyName)
|
||||
{
|
||||
PropertyInfo property = typeof(ConsoleOptions).GetProperty(propertyName);
|
||||
Assert.IsNotNull(property, "The property '{0}' is not defined", propertyName);
|
||||
return property;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
using Options;
|
||||
|
||||
public class MakeTestPackageTests
|
||||
{
|
||||
[Test]
|
||||
public void SingleAssembly()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.AreEqual(1, package.TestFiles.Length);
|
||||
Assert.AreEqual(Path.GetFullPath("test.dll"), package.FullName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleAssemblies()
|
||||
{
|
||||
var names = new [] { "test1.dll", "test2.dll", "test3.dll" };
|
||||
var expected = new[] {
|
||||
Path.GetFullPath("test1.dll"),
|
||||
Path.GetFullPath("test2.dll"),
|
||||
Path.GetFullPath("test3.dll")
|
||||
};
|
||||
var options = new ConsoleOptions(names);
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.AreEqual(expected, package.TestFiles);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenTimeoutIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--timeout=50");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("DefaultTimeout"));
|
||||
Assert.AreEqual(50, package.Settings["DefaultTimeout"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenProcessModelIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--process=Separate");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("ProcessModel"));
|
||||
Assert.AreEqual("Separate", package.Settings["ProcessModel"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenDomainUsageIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--domain=Multiple");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("DomainUsage"));
|
||||
Assert.AreEqual("Multiple", package.Settings["DomainUsage"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenFrameworkIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--framework=net-4.0");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("RuntimeFramework"));
|
||||
Assert.AreEqual("net-4.0", package.Settings["RuntimeFramework"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenConfigIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--config=Release");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("ActiveConfig"));
|
||||
Assert.AreEqual("Release", package.Settings["ActiveConfig"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenTraceIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--trace=Error");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("InternalTraceLevel"));
|
||||
Assert.AreEqual("Error", package.Settings["InternalTraceLevel"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenSeedIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--seed=1234");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("RandomSeed"));
|
||||
Assert.AreEqual(1234, package.Settings["RandomSeed"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenWorkersIsSpecified_PackageIncludesIt()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll", "--workers=3");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.That(package.Settings.ContainsKey("NumberOfTestWorkers"));
|
||||
Assert.AreEqual(3, package.Settings["NumberOfTestWorkers"]);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void EnumOptions_MayBeSpecifiedAsInts()
|
||||
//{
|
||||
// var options = new ConsoleOptions("test.dll", "--trace=4");
|
||||
// var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
// Assert.That(package.Settings.ContainsKey("InternalTraceLevel"));
|
||||
// Assert.AreEqual("Info", package.Settings["InternalTraceLevel"]);
|
||||
//}
|
||||
|
||||
//[Test]
|
||||
//public void EnumOptions_InvalidNamesCauseAnError()
|
||||
//{
|
||||
// var options = new ConsoleOptions("test.dll", "--trace=All");
|
||||
// Assert.False(options.Validate());
|
||||
//}
|
||||
|
||||
//[Test]
|
||||
//public void EnumOptions_OutOfRangeValuesAreUsedAsIs()
|
||||
//{
|
||||
// var options = new ConsoleOptions("test.dll", "--trace=7");
|
||||
// var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
// Assert.That(package.Settings.ContainsKey("InternalTraceLevel"));
|
||||
// Assert.AreEqual(7, package.Settings["InternalTraceLevel"]);
|
||||
//}
|
||||
|
||||
[Test]
|
||||
public void WhenNoOptionsAreSpecified_PackageContainsNoSettings()
|
||||
{
|
||||
var options = new ConsoleOptions("test.dll");
|
||||
var package = ConsoleRunner.MakeTestPackage(options);
|
||||
|
||||
Assert.AreEqual(0, package.Settings.Count);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
|
||||
<xs:complexType name="failureType">
|
||||
<xs:sequence>
|
||||
<xs:element ref="message" />
|
||||
<xs:element ref="stack-trace" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="reasonType">
|
||||
<xs:sequence>
|
||||
<xs:element ref="message" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:element name="message" type="xs:string" />
|
||||
<xs:complexType name="resultsType">
|
||||
<xs:choice>
|
||||
<xs:element name="test-suite" type="test-suiteType" maxOccurs="unbounded" />
|
||||
<xs:element name="test-case" type="test-caseType" maxOccurs="unbounded" minOccurs="0" />
|
||||
</xs:choice>
|
||||
</xs:complexType>
|
||||
<xs:element name="stack-trace" type="xs:string" />
|
||||
<xs:element name="test-results" type="resultType" />
|
||||
<xs:complexType name="categoriesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="category" type="categoryType" maxOccurs="unbounded" minOccurs="1" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="categoryType">
|
||||
<xs:attribute name="name" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="propertiesType">
|
||||
<xs:sequence>
|
||||
<xs:element name="property" type="propertyType" maxOccurs="unbounded" minOccurs="1" />
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:complexType name="propertyType">
|
||||
<xs:attribute name="name" type="xs:string" use="required" />
|
||||
<xs:attribute name="value" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="environmentType">
|
||||
<xs:attribute name="nunit-version" type="xs:string" use="required" />
|
||||
<xs:attribute name="clr-version" type="xs:string" use="required" />
|
||||
<xs:attribute name="os-version" type="xs:string" use="required" />
|
||||
<xs:attribute name="platform" type="xs:string" use="required" />
|
||||
<xs:attribute name="cwd" type="xs:string" use="required" />
|
||||
<xs:attribute name="machine-name" type="xs:string" use="required" />
|
||||
<xs:attribute name="user" type="xs:string" use="required" />
|
||||
<xs:attribute name="user-domain" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="culture-infoType">
|
||||
<xs:attribute name="current-culture" type="xs:string" use="required" />
|
||||
<xs:attribute name="current-uiculture" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="resultType">
|
||||
<xs:sequence>
|
||||
<xs:element name="environment" type="environmentType" />
|
||||
<xs:element name="culture-info" type="culture-infoType" />
|
||||
<xs:element name="test-suite" type="test-suiteType" />
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required" />
|
||||
<xs:attribute name="total" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="errors" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="failures" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="inconclusive" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="not-run" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="ignored" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="skipped" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="invalid" type="xs:decimal" use="required" />
|
||||
<xs:attribute name="date" type="xs:string" use="required" />
|
||||
<xs:attribute name="time" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="test-caseType">
|
||||
<xs:sequence>
|
||||
<xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" />
|
||||
<xs:element name="properties" type="propertiesType" minOccurs="0" maxOccurs="1" />
|
||||
<xs:choice>
|
||||
<xs:element name="failure" type="failureType" minOccurs="0" />
|
||||
<xs:element name="reason" type="reasonType" minOccurs="0" />
|
||||
</xs:choice>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" type="xs:string" use="required" />
|
||||
<xs:attribute name="description" type="xs:string" use="optional" />
|
||||
<xs:attribute name="success" type="xs:string" use="optional" />
|
||||
<xs:attribute name="time" type="xs:string" use="optional" />
|
||||
<xs:attribute name="executed" type="xs:string" use="required" />
|
||||
<xs:attribute name="asserts" type="xs:string" use="optional" />
|
||||
<xs:attribute name="result" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
<xs:complexType name="test-suiteType">
|
||||
<xs:sequence>
|
||||
<xs:element name="categories" type="categoriesType" minOccurs="0" maxOccurs="1" />
|
||||
<xs:element name="properties" type="propertiesType" minOccurs="0" maxOccurs="1" />
|
||||
<xs:choice>
|
||||
<xs:element name="failure" type="failureType" minOccurs="0" />
|
||||
<xs:element name="reason" type="reasonType" minOccurs="0" />
|
||||
</xs:choice>
|
||||
<xs:element name="results" type="resultsType" minOccurs="0" maxOccurs="1"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="type" type="xs:string" use="required" />
|
||||
<xs:attribute name="name" type="xs:string" use="required" />
|
||||
<xs:attribute name="description" type="xs:string" use="optional" />
|
||||
<xs:attribute name="success" type="xs:string" use="optional" />
|
||||
<xs:attribute name="time" type="xs:string" use="optional" />
|
||||
<xs:attribute name="executed" type="xs:string" use="required" />
|
||||
<xs:attribute name="asserts" type="xs:string" use="optional" />
|
||||
<xs:attribute name="result" type="xs:string" use="required" />
|
||||
</xs:complexType>
|
||||
</xs:schema>
|
|
@ -0,0 +1,81 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NUnit2XmlValidationTests : XmlOutputTest
|
||||
{
|
||||
private SchemaValidator validator;
|
||||
|
||||
private static readonly string schemaFile = "NUnit2TestResult.xsd";
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void InitializeValidator()
|
||||
{
|
||||
this.validator = new SchemaValidator(GetLocalPath(schemaFile));
|
||||
}
|
||||
|
||||
[Test,SetCulture("")]
|
||||
public void TestSchemaValidatorInvariantCulture()
|
||||
{
|
||||
runSchemaValidatorTest();
|
||||
}
|
||||
|
||||
[Test,SetCulture("en-US")]
|
||||
public void TestSchemaValidatorUnitedStatesCulture()
|
||||
{
|
||||
runSchemaValidatorTest();
|
||||
}
|
||||
|
||||
[Test,SetCulture("fr-FR")]
|
||||
public void TestSchemaValidatorFrenchCulture()
|
||||
{
|
||||
runSchemaValidatorTest();
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private void runSchemaValidatorTest()
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
new NUnit2XmlOutputWriter().WriteResultFile(this.EngineResult.Xml, new StringWriter(output));
|
||||
|
||||
if (!validator.Validate(new StringReader(output.ToString())))
|
||||
{
|
||||
StringBuilder errors = new StringBuilder("Validation Errors:" + Environment.NewLine);
|
||||
foreach (string error in validator.Errors)
|
||||
errors.Append(" " + error + Environment.NewLine);
|
||||
Assert.Fail(errors.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
public class OutputSpecificationTests
|
||||
{
|
||||
[Test]
|
||||
public void SpecMayNotBeNull()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification(null),
|
||||
Throws.TypeOf<NullReferenceException>());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void SpecOptionMustContainEqualSign()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification("MyFile.xml;transform.xslt"),
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SpecOptionMustContainJustOneEqualSign()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification("MyFile.xml;transform=xslt=transform.xslt"),
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FileNameOnly()
|
||||
{
|
||||
var spec = new OutputSpecification("MyFile.xml");
|
||||
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
|
||||
Assert.That(spec.Format, Is.EqualTo("nunit3"));
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FileNamePlusFormat()
|
||||
{
|
||||
var spec = new OutputSpecification("MyFile.xml;format=nunit2");
|
||||
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
|
||||
Assert.That(spec.Format, Is.EqualTo("nunit2"));
|
||||
Assert.Null(spec.Transform);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FileNamePlusTransform()
|
||||
{
|
||||
var spec = new OutputSpecification("MyFile.xml;transform=transform.xslt");
|
||||
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
|
||||
Assert.That(spec.Format, Is.EqualTo("user"));
|
||||
Assert.That(spec.Transform, Is.EqualTo("transform.xslt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UserFormatMayBeIndicatedExplicitlyAfterTransform()
|
||||
{
|
||||
var spec = new OutputSpecification("MyFile.xml;transform=transform.xslt;format=user");
|
||||
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
|
||||
Assert.That(spec.Format, Is.EqualTo("user"));
|
||||
Assert.That(spec.Transform, Is.EqualTo("transform.xslt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UserFormatMayBeIndicatedExplicitlyBeforeTransform()
|
||||
{
|
||||
var spec = new OutputSpecification("MyFile.xml;format=user;transform=transform.xslt");
|
||||
Assert.That(spec.OutputPath, Is.EqualTo("MyFile.xml"));
|
||||
Assert.That(spec.Format, Is.EqualTo("user"));
|
||||
Assert.That(spec.Transform, Is.EqualTo("transform.xslt"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleFormatSpecifiersNotAllowed()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification("MyFile.xml;format=nunit2;format=nunit3"),
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleTransformSpecifiersNotAllowed()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification("MyFile.xml;transform=transform1.xslt;transform=transform2.xslt"),
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TransformWithNonUserFormatNotAllowed()
|
||||
{
|
||||
Assert.That(
|
||||
() => new OutputSpecification("MyFile.xml;format=nunit2;transform=transform.xslt"),
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("nunit-console.tests")]
|
||||
[assembly: AssemblyDescription("Tests of the NUnit Console Runner")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f5209525-004e-44bc-8e19-9616924467ea")]
|
|
@ -0,0 +1,85 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Schema;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
public class SchemaValidator
|
||||
{
|
||||
private XmlReaderSettings settings;
|
||||
private List<string> errors;
|
||||
|
||||
public SchemaValidator(string schemaFile)
|
||||
{
|
||||
this.settings = new XmlReaderSettings();
|
||||
settings.ValidationType = ValidationType.Schema;
|
||||
settings.Schemas.Add(XmlSchema.Read(
|
||||
new StreamReader(schemaFile),
|
||||
new ValidationEventHandler(ValidationEventHandle)));
|
||||
}
|
||||
|
||||
public string[] Errors
|
||||
{
|
||||
get { return errors.ToArray(); }
|
||||
}
|
||||
|
||||
public bool Validate(string xmlFile)
|
||||
{
|
||||
return Validate(new StreamReader(xmlFile));
|
||||
}
|
||||
|
||||
public bool Validate(TextReader rdr)
|
||||
{
|
||||
this.errors = new List<string>();
|
||||
|
||||
XmlReader myXmlValidatingReader = XmlReader.Create(rdr, this.settings);
|
||||
|
||||
try
|
||||
{
|
||||
// Read XML data
|
||||
while (myXmlValidatingReader.Read()) { }
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Assert.Fail(e.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
myXmlValidatingReader.Close();
|
||||
}
|
||||
|
||||
return errors.Count == 0;
|
||||
}
|
||||
|
||||
public void ValidationEventHandle(object sender, ValidationEventArgs args)
|
||||
{
|
||||
errors.Add(args.Message);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
using NUnit.Engine;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities.Tests
|
||||
{
|
||||
public class TestFilterBuilderTests
|
||||
{
|
||||
TestFilterBuilder builder;
|
||||
|
||||
[SetUp]
|
||||
public void CreateBuilder()
|
||||
{
|
||||
this.builder = new TestFilterBuilder();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyFilter()
|
||||
{
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
Assert.That(filter.Text, Is.EqualTo("<filter></filter>"));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
Assert.That(filter.Xml.ChildNodes.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OneTestSelected()
|
||||
{
|
||||
builder.Tests.Add("My.Test.Name");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><tests><test>My.Test.Name</test></tests></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
Assert.That(filter.Xml.SelectSingleNode("tests/test").InnerText, Is.EqualTo("My.Test.Name"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThreeTestsSelected()
|
||||
{
|
||||
builder.Tests.Add("My.First.Test");
|
||||
builder.Tests.Add("My.Second.Test");
|
||||
builder.Tests.Add("My.Third.Test");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><tests><test>My.First.Test</test><test>My.Second.Test</test><test>My.Third.Test</test></tests></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
XmlNodeList testNodes = filter.Xml.SelectNodes("tests/test");
|
||||
Assert.That(testNodes.Count, Is.EqualTo(3));
|
||||
Assert.That(testNodes[0].InnerText, Is.EqualTo("My.First.Test"));
|
||||
Assert.That(testNodes[1].InnerText, Is.EqualTo("My.Second.Test"));
|
||||
Assert.That(testNodes[2].InnerText, Is.EqualTo("My.Third.Test"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OneCategoryIncluded()
|
||||
{
|
||||
builder.Include.Add("Dummy");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><cat>Dummy</cat></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThreeCategoriesIncluded()
|
||||
{
|
||||
builder.Include.Add("Dummy");
|
||||
builder.Include.Add("Another");
|
||||
builder.Include.Add("StillAnother");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><cat>Dummy,Another,StillAnother</cat></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OneCategoryExcluded()
|
||||
{
|
||||
builder.Exclude.Add("Dummy");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><not><cat>Dummy</cat></not></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ThreeCategoriesExcluded()
|
||||
{
|
||||
builder.Exclude.Add("Dummy");
|
||||
builder.Exclude.Add("Another");
|
||||
builder.Exclude.Add("StillAnother");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><not><cat>Dummy,Another,StillAnother</cat></not></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OneTestAndOneCategory()
|
||||
{
|
||||
builder.Tests.Add("My.Test.Name");
|
||||
builder.Include.Add("Dummy");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><tests><test>My.Test.Name</test></tests><cat>Dummy</cat></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TwoCategoriesIncludedAndOneExcluded()
|
||||
{
|
||||
builder.Include.Add("Dummy");
|
||||
builder.Include.Add("Another");
|
||||
builder.Exclude.Add("Slow");
|
||||
TestFilter filter = builder.GetFilter();
|
||||
|
||||
string expectedText = "<filter><cat>Dummy,Another</cat><not><cat>Slow</cat></not></filter>";
|
||||
Assert.That(filter.Text, Is.EqualTo(expectedText));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities.Tests
|
||||
{
|
||||
public class TestNameParserTests
|
||||
{
|
||||
[TestCase("Test.Namespace.Fixture.Method")]
|
||||
[TestCase("Test.Namespace.Fixture.Method,")]
|
||||
[TestCase(" Test.Namespace.Fixture.Method ")]
|
||||
[TestCase(" Test.Namespace.Fixture.Method ,")]
|
||||
[TestCase("Test.Namespace.Fixture.Method()")]
|
||||
[TestCase("Test.Namespace.Fixture.Method(\"string,argument\")")]
|
||||
[TestCase("Test.Namespace.Fixture.Method(1,2,3)")]
|
||||
[TestCase("Test.Namespace.Fixture.Method<int,int>()")]
|
||||
[TestCase("Test.Namespace.Fixture.Method(\")\")")]
|
||||
public void SingleName(string name)
|
||||
{
|
||||
string[] names = TestNameParser.Parse(name);
|
||||
Assert.AreEqual(1, names.Length);
|
||||
Assert.AreEqual(name.Trim(new char[] { ' ', ',' }), names[0]);
|
||||
}
|
||||
|
||||
[TestCase("Test.Namespace.Fixture.Method1", "Test.Namespace.Fixture.Method2")]
|
||||
[TestCase("Test.Namespace.Fixture.Method1", "Test.Namespace.Fixture.Method2,")] // <= trailing comma
|
||||
[TestCase("Test.Namespace.Fixture.Method1(1,2)", "Test.Namespace.Fixture.Method2(3,4)")]
|
||||
[TestCase("Test.Namespace.Fixture.Method1(\"(\")", "Test.Namespace.Fixture.Method2(\"<\")")]
|
||||
public void TwoNames(string name1, string name2)
|
||||
{
|
||||
char[] delims = new char[] { ' ', ',' };
|
||||
string[] names = TestNameParser.Parse(name1 + "," + name2);
|
||||
Assert.AreEqual(2, names.Length);
|
||||
Assert.AreEqual(name1.Trim(delims), names[0]);
|
||||
Assert.AreEqual(name2.Trim(delims), names[1]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method='text'/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<xsl:apply-templates/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="test-run">
|
||||
<xsl:text>NUnit Version </xsl:text>
|
||||
<xsl:value-of select="environment/@nunit-version"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@start-time"/>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="@end-time"/>
|
||||
<xsl:text>

</xsl:text>
|
||||
|
||||
<xsl:text>Runtime Environment -
</xsl:text>
|
||||
<xsl:text> OS Version: </xsl:text>
|
||||
<xsl:value-of select="environment/@os-version"/>
|
||||
<xsl:text>
</xsl:text>
|
||||
<xsl:text> CLR Version: </xsl:text>
|
||||
<xsl:value-of select="environment/@clr-version"/>
|
||||
<xsl:text>

</xsl:text>
|
||||
|
||||
<xsl:text>Tests Run: </xsl:text>
|
||||
<xsl:value-of select="@total"/>
|
||||
|
||||
<xsl:text>, Passed: </xsl:text>
|
||||
<xsl:value-of select="@passed"/>
|
||||
<xsl:text>, Failed: </xsl:text>
|
||||
<xsl:value-of select="@failed"/>
|
||||
<xsl:text>, Inconclusive: </xsl:text>
|
||||
<xsl:value-of select="@inconclusive"/>
|
||||
<xsl:text>, Skipped: </xsl:text>
|
||||
<xsl:value-of select="@skipped"/>
|
||||
|
||||
<xsl:text>, Elapsed Time: </xsl:text>
|
||||
<xsl:value-of select="@duration"/>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -0,0 +1,51 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities.Tests
|
||||
{
|
||||
public class XmlHelperTests
|
||||
{
|
||||
[Test]
|
||||
public void SingleElement()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("myelement");
|
||||
|
||||
Assert.That(node.Name, Is.EqualTo("myelement"));
|
||||
Assert.That(node.Attributes.Count, Is.EqualTo(0));
|
||||
Assert.That(node.ChildNodes.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeAttributeAccess()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("top");
|
||||
|
||||
Assert.That(node.GetAttribute("junk"), Is.Null);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
using Engine;
|
||||
using Engine.Internal;
|
||||
using Framework;
|
||||
|
||||
using Runner = NUnit.Framework.Api.NUnitTestAssemblyRunner;
|
||||
using Builder = NUnit.Framework.Api.DefaultTestAssemblyBuilder;
|
||||
using TestListener = NUnit.Framework.Internal.TestListener;
|
||||
using TestFilter = NUnit.Framework.Internal.TestFilter;
|
||||
|
||||
/// <summary>
|
||||
/// This is the abstract base for all XML output tests,
|
||||
/// which need to work on a TestEngineResult. Creating a
|
||||
/// second level engine in the test domain causes
|
||||
/// problems, so this class uses internal framework
|
||||
/// classes to run the test and then transforms the XML
|
||||
/// result into a TestEngineResult for use by derived tests.
|
||||
/// </summary>
|
||||
public abstract class XmlOutputTest
|
||||
{
|
||||
private ITestEngine engine;
|
||||
private string localDirectory;
|
||||
|
||||
protected TestEngineResult EngineResult { get; private set; }
|
||||
|
||||
// Method used by deribed classes to get the path to a file name
|
||||
protected string GetLocalPath(string fileName)
|
||||
{
|
||||
return Path.Combine(localDirectory, fileName);
|
||||
}
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void InitializeTestEngineResult()
|
||||
{
|
||||
// Save the local directory - used by GetLocalPath
|
||||
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
|
||||
localDirectory = Path.GetDirectoryName(uri.LocalPath);
|
||||
|
||||
// Create a fresh copy of the engine, since we can't use the
|
||||
// one that is running this test.
|
||||
engine = TestEngineActivator.CreateInstance();
|
||||
engine.InternalTraceLevel = InternalTraceLevel.Off;
|
||||
|
||||
// Create a new DefaultAssemblyRunner, which is actually a framework class,
|
||||
// because we can't use the one that's currently running this test.
|
||||
var runner = new Runner(new Builder());
|
||||
var assemblyPath = GetLocalPath("mock-assembly.dll");
|
||||
var settings = new Dictionary<string, object>();
|
||||
|
||||
// Make sure the runner loaded the mock assembly.
|
||||
Assert.That(
|
||||
runner.Load(assemblyPath, settings).RunState.ToString(),
|
||||
Is.EqualTo("Runnable"),
|
||||
"Unable to load mock-assembly.dll");
|
||||
|
||||
// Run the tests, saving the result as an XML string
|
||||
var xmlText = runner.Run(TestListener.NULL, TestFilter.Empty).ToXml(true).OuterXml;
|
||||
|
||||
// Create a TestEngineResult from the string, just as the TestEngine does,
|
||||
// then add a test-run element to the result, wrapping the result so it
|
||||
// looks just like what the engine would return!
|
||||
this.EngineResult = new TestEngineResult(xmlText).Aggregate("test-run", "NAME", "FULLNAME");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Tests
|
||||
{
|
||||
public class XmlTransformOutputWriterTests : XmlOutputTest
|
||||
{
|
||||
[Test]
|
||||
public void SummaryTransformTest()
|
||||
{
|
||||
var transformPath = GetLocalPath("TextSummary.xslt");
|
||||
StringWriter writer = new StringWriter();
|
||||
new XmlTransformOutputWriter(transformPath).WriteResultFile(EngineResult.Xml, writer);
|
||||
|
||||
string summary = string.Format(
|
||||
"Tests Run: {0}, Passed: {1}, Failed: {2}, Inconclusive: {3}, Skipped: {4}",
|
||||
EngineResult.Xml.Attributes["total"].Value,
|
||||
EngineResult.Xml.Attributes["passed"].Value,
|
||||
EngineResult.Xml.Attributes["failed"].Value,
|
||||
EngineResult.Xml.Attributes["inconclusive"].Value,
|
||||
EngineResult.Xml.Attributes["skipped"].Value);
|
||||
|
||||
string output = writer.GetStringBuilder().ToString();
|
||||
|
||||
Assert.That(output, Contains.Substring(summary));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnit-Console.Tests" default="build">
|
||||
|
||||
<patternset id="source-files">
|
||||
<include name="Properties/AssemblyInfo.cs" />
|
||||
<include name="ColorConsoleTests.cs" />
|
||||
<include name="ColorStyleTests.cs" />
|
||||
<include name="CommandLineTests.cs" />
|
||||
<include name="MakeTestPackageTests.cs" />
|
||||
<include name="NUnit2XmlValidationTests.cs" />
|
||||
<include name="OutputSpecificationTests.cs"/>
|
||||
<include name="SchemaValidator.cs" />
|
||||
<include name="TestFilterBuilderTests.cs" />
|
||||
<include name="TestFilterTests.cs" />
|
||||
<include name="TestNameParserTests.cs" />
|
||||
<include name="XmlHelper.cs" />
|
||||
<include name="XmlOutputTest.cs" />
|
||||
<include name="XmlTransformOutputWriterTests.cs"/>
|
||||
</patternset>
|
||||
|
||||
<target name="build">
|
||||
<csc target="library"
|
||||
output="${current.build.dir}/nunit-console.tests.dll"
|
||||
debug="${build.debug}" define="${build.defines}">
|
||||
<sources>
|
||||
<patternset refid="source-files"/>
|
||||
<include name="../../GeneratedAssemblyInfo.cs"/>
|
||||
</sources>
|
||||
<nowarn>
|
||||
<warning number="1699"/>
|
||||
</nowarn>
|
||||
<references basedir="${current.build.dir}">
|
||||
<include name="nunit.framework.dll"/>
|
||||
<include name="nunit.engine.api.dll"/>
|
||||
<include name="nunit.engine.dll"/>
|
||||
<include name="nunit-console.exe"/>
|
||||
</references>
|
||||
</csc>
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
<copy todir="${package.src.dir}/nunit-console.tests">
|
||||
<fileset>
|
||||
<patternset refid="source-files"/>
|
||||
<include name="*.csproj"/>
|
||||
<include name="*.build"/>
|
||||
<include name="NUnit2TestResult.xsd"/>
|
||||
<include name="TextSummary.xslt"/>
|
||||
<include name="App.ico"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{B310A760-8AE1-41CA-81F8-03B12E2FCE30}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.ConsoleRunner.Tests</RootNamespace>
|
||||
<AssemblyName>nunit-console.tests</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;CLR_4_0;CS_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;CLR_4_0;CS_4_0</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework, Version=2.6.0.12017, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\CommonVersionInfo.cs">
|
||||
<Link>CommonVersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ColorConsoleTests.cs" />
|
||||
<Compile Include="ColorStyleTests.cs" />
|
||||
<Compile Include="CommandLineTests.cs" />
|
||||
<Compile Include="MakeTestPackageTests.cs" />
|
||||
<Compile Include="NUnit2XmlValidationTests.cs" />
|
||||
<Compile Include="OutputSpecificationTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SchemaValidator.cs" />
|
||||
<Compile Include="TestFilterBuilderTests.cs" />
|
||||
<Compile Include="TestNameParserTests.cs" />
|
||||
<Compile Include="XmlHelperTests.cs" />
|
||||
<Compile Include="XmlOutputTest.cs" />
|
||||
<Compile Include="XmlTransformOutputWriterTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="TextSummary.xslt">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="nunit-console.tests.build" />
|
||||
<Content Include="NUnit2TestResult.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\nunit-console\nunit-console.csproj">
|
||||
<Project>{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}</Project>
|
||||
<Name>nunit-console</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\nunit.engine.api\nunit.engine.api.csproj">
|
||||
<Project>{775fad50-3623-4922-97c4-dfb29a8be4c7}</Project>
|
||||
<Name>nunit.engine.api</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\nunit.engine\nunit.engine.csproj">
|
||||
<Project>{372a3447-d657-40ff-a089-77c19fec30c8}</Project>
|
||||
<Name>nunit.engine</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 1.1 KiB |
|
@ -0,0 +1,301 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using NUnit.Engine;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Options;
|
||||
using Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// ConsoleRunner provides the nunit-console text-based
|
||||
/// user interface, running the tests and reporting the results.
|
||||
/// </summary>
|
||||
public class ConsoleRunner
|
||||
{
|
||||
#region Console Runner Return Codes
|
||||
|
||||
public static readonly int OK = 0;
|
||||
public static readonly int INVALID_ARG = -1;
|
||||
public static readonly int FILE_NOT_FOUND = -2;
|
||||
public static readonly int FIXTURE_NOT_FOUND = -3;
|
||||
public static readonly int UNEXPECTED_ERROR = -100;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Instance Fields
|
||||
|
||||
private ITestEngine _engine;
|
||||
private ConsoleOptions _options;
|
||||
|
||||
private TextWriter _outWriter = Console.Out;
|
||||
private TextWriter _errorWriter = Console.Error;
|
||||
|
||||
private string _workDirectory;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public ConsoleRunner(ITestEngine engine, ConsoleOptions options)
|
||||
{
|
||||
_engine = engine;
|
||||
_options = options;
|
||||
_workDirectory = options.WorkDirectory;
|
||||
if (_workDirectory == null)
|
||||
_workDirectory = Environment.CurrentDirectory;
|
||||
else if (!Directory.Exists(_workDirectory))
|
||||
Directory.CreateDirectory(_workDirectory);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Execute Method
|
||||
|
||||
/// <summary>
|
||||
/// Executes tests according to the provided commandline options.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public int Execute()
|
||||
{
|
||||
TestPackage package = MakeTestPackage(_options);
|
||||
|
||||
TestFilter filter = CreateTestFilter(_options);
|
||||
|
||||
if (_options.Explore)
|
||||
return ExploreTests(package, filter);
|
||||
else
|
||||
return RunTests(package, filter);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private int ExploreTests(TestPackage package, TestFilter filter)
|
||||
{
|
||||
XmlNode result = null;
|
||||
|
||||
using (var runner = _engine.GetRunner(package))
|
||||
result = runner.Explore(filter);
|
||||
|
||||
if (_options.ExploreOutputSpecifications.Count == 0)
|
||||
{
|
||||
new TestCaseOutputWriter().WriteResultFile(result, Console.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
var outputManager = new OutputManager(result, _workDirectory);
|
||||
|
||||
foreach (OutputSpecification spec in _options.ExploreOutputSpecifications)
|
||||
outputManager.WriteTestFile(spec);
|
||||
}
|
||||
|
||||
return ConsoleRunner.OK;
|
||||
}
|
||||
|
||||
private int RunTests(TestPackage package, TestFilter filter)
|
||||
{
|
||||
// TODO: We really need options as resolved by engine for most of these
|
||||
DisplayRequestedOptions();
|
||||
|
||||
// TODO: Incorporate this in EventCollector?
|
||||
RedirectOutputAsRequested();
|
||||
|
||||
var labels = _options.DisplayTestLabels != null
|
||||
? _options.DisplayTestLabels.ToUpperInvariant()
|
||||
: "ON";
|
||||
TestEventHandler eventHandler = new TestEventHandler(_outWriter, labels);
|
||||
|
||||
XmlNode result = null;
|
||||
|
||||
// Save things that might be messed up by a bad test
|
||||
TextWriter savedOut = Console.Out;
|
||||
TextWriter savedError = Console.Error;
|
||||
|
||||
DateTime startTime = DateTime.Now;
|
||||
|
||||
try
|
||||
{
|
||||
using ( new ColorConsole( ColorStyle.Output ) )
|
||||
using (ITestRunner runner = _engine.GetRunner(package))
|
||||
{
|
||||
result = runner.Run(eventHandler, filter);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.SetOut(savedOut);
|
||||
Console.SetError(savedError);
|
||||
|
||||
RestoreOutput();
|
||||
}
|
||||
|
||||
//Console.WriteLine();
|
||||
|
||||
ResultReporter reporter = new ResultReporter(result, _options);
|
||||
reporter.ReportResults();
|
||||
|
||||
// TODO: Inject this?
|
||||
var outputManager = new OutputManager(result, _workDirectory);
|
||||
|
||||
foreach (var outputSpec in _options.ResultOutputSpecifications)
|
||||
outputManager.WriteResultFile(outputSpec, startTime);
|
||||
|
||||
return reporter.Summary.ErrorsAndFailures;
|
||||
}
|
||||
|
||||
private void DisplayRequestedOptions()
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Options");
|
||||
ColorConsole.WriteLabel(" ProcessModel: ", _options.ProcessModel ?? "Default", false);
|
||||
ColorConsole.WriteLabel(" DomainUsage: ", _options.DomainUsage ?? "Default", true);
|
||||
ColorConsole.WriteLabel(" Execution Runtime: ", _options.Framework ?? "Not Specified", true);
|
||||
if (_options.DefaultTimeout >= 0)
|
||||
ColorConsole.WriteLabel(" Default timeout: ", _options.DefaultTimeout.ToString(), true);
|
||||
if (_options.NumWorkers > 0)
|
||||
ColorConsole.WriteLabel(" Worker Threads: ", _options.NumWorkers.ToString(), true);
|
||||
ColorConsole.WriteLabel(" Work Directory: ", _workDirectory, true);
|
||||
ColorConsole.WriteLabel(" Internal Trace: ", _options.InternalTraceLevel ?? "Off", true);
|
||||
//if (options.DisplayTeamCityServiceMessages)
|
||||
// ColorConsole.WriteLine(" Display TeamCity Service Messages");
|
||||
Console.WriteLine();
|
||||
|
||||
if (_options.TestList.Count > 0)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Label, "Selected test(s):");
|
||||
using (new ColorConsole(ColorStyle.Default))
|
||||
foreach (string testName in _options.TestList)
|
||||
Console.WriteLine(" " + testName);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty( _options.Include ))
|
||||
ColorConsole.WriteLabel("Included categories: ", _options.Include, true);
|
||||
|
||||
if (!string.IsNullOrEmpty( _options.Exclude ))
|
||||
ColorConsole.WriteLabel("Excluded categories: ", _options.Exclude, true);
|
||||
}
|
||||
|
||||
private void RedirectOutputAsRequested()
|
||||
{
|
||||
if (_options.OutFile != null)
|
||||
{
|
||||
var outStreamWriter = new StreamWriter(Path.Combine(_workDirectory, _options.OutFile));
|
||||
outStreamWriter.AutoFlush = true;
|
||||
_outWriter = outStreamWriter;
|
||||
}
|
||||
|
||||
if (_options.ErrFile != null)
|
||||
{
|
||||
var errorStreamWriter = new StreamWriter(Path.Combine(_workDirectory, _options.ErrFile));
|
||||
errorStreamWriter.AutoFlush = true;
|
||||
_errorWriter = errorStreamWriter;
|
||||
}
|
||||
}
|
||||
|
||||
private void RestoreOutput()
|
||||
{
|
||||
_outWriter.Flush();
|
||||
if (_options.OutFile != null)
|
||||
_outWriter.Close();
|
||||
|
||||
_errorWriter.Flush();
|
||||
if (_options.ErrFile != null)
|
||||
_errorWriter.Close();
|
||||
}
|
||||
|
||||
// This is public static for ease of testing
|
||||
public static TestPackage MakeTestPackage( ConsoleOptions options )
|
||||
{
|
||||
TestPackage package = options.InputFiles.Count == 1
|
||||
? new TestPackage(options.InputFiles[0])
|
||||
: new TestPackage(options.InputFiles);
|
||||
|
||||
if (options.ProcessModel != null)//ProcessModel.Default)
|
||||
package.Settings[PackageSettings.ProcessModel] = options.ProcessModel;
|
||||
|
||||
if (options.DomainUsage != null)
|
||||
package.Settings[PackageSettings.DomainUsage] = options.DomainUsage;
|
||||
|
||||
if (options.Framework != null)
|
||||
package.Settings[PackageSettings.RuntimeFramework] = options.Framework;
|
||||
|
||||
if (options.DefaultTimeout >= 0)
|
||||
package.Settings[PackageSettings.DefaultTimeout] = options.DefaultTimeout;
|
||||
|
||||
if (options.InternalTraceLevel != null)
|
||||
package.Settings[PackageSettings.InternalTraceLevel] = options.InternalTraceLevel;
|
||||
|
||||
if (options.ActiveConfig != null)
|
||||
package.Settings[PackageSettings.ActiveConfig] = options.ActiveConfig;
|
||||
|
||||
if (options.WorkDirectory != null)
|
||||
package.Settings[PackageSettings.WorkDirectory] = options.WorkDirectory;
|
||||
|
||||
if (options.StopOnError)
|
||||
package.Settings[PackageSettings.StopOnError] = true;
|
||||
|
||||
if (options.NumWorkers > 0)
|
||||
package.Settings[PackageSettings.NumberOfTestWorkers] = options.NumWorkers;
|
||||
|
||||
if (options.RandomSeed > 0)
|
||||
package.Settings[PackageSettings.RandomSeed] = options.RandomSeed;
|
||||
|
||||
if (options.Verbose)
|
||||
package.Settings["Verbose"] = true;
|
||||
|
||||
#if DEBUG
|
||||
//foreach (KeyValuePair<string, object> entry in package.Settings)
|
||||
// if (!(entry.Value is string || entry.Value is int || entry.Value is bool))
|
||||
// throw new Exception(string.Format("Package setting {0} is not a valid type", entry.Key));
|
||||
#endif
|
||||
|
||||
return package;
|
||||
}
|
||||
|
||||
// This is public static for ease of testing
|
||||
public static TestFilter CreateTestFilter(ConsoleOptions options)
|
||||
{
|
||||
TestFilterBuilder builder = new TestFilterBuilder();
|
||||
foreach (string testName in options.TestList)
|
||||
builder.Tests.Add(testName);
|
||||
|
||||
// TODO: Support multiple include / exclude options
|
||||
|
||||
if (options.Include != null)
|
||||
builder.Include.Add(options.Include);
|
||||
|
||||
if (options.Exclude != null)
|
||||
builder.Exclude.Add(options.Exclude);
|
||||
|
||||
return builder.GetFilter();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
public interface IResultWriter
|
||||
{
|
||||
void WriteResultFile(XmlNode resultNode, string outputPath);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,315 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Mono.Options;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Options
|
||||
{
|
||||
using Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// ConsoleOptions encapsulates the option settings for
|
||||
/// the nunit-console program. It inherits from the Mono
|
||||
/// Options OptionSet class and provides a central location
|
||||
/// for defining and parsing options.
|
||||
/// </summary>
|
||||
public class ConsoleOptions : OptionSet
|
||||
{
|
||||
private bool validated;
|
||||
private bool noresult;
|
||||
|
||||
#region Constructor
|
||||
|
||||
public ConsoleOptions(params string[] args)
|
||||
{
|
||||
// NOTE: The order in which patterns are added
|
||||
// determines the display order for the help.
|
||||
|
||||
// Old Options no longer supported:
|
||||
// fixture
|
||||
// xmlConsole
|
||||
// noshadow
|
||||
// nothread
|
||||
// nodots
|
||||
|
||||
// Options to be added:
|
||||
// teamcity
|
||||
// workers
|
||||
|
||||
// Select Tests
|
||||
this.Add("test=", "Comma-separated list of {NAMES} of tests to run or explore. This option may be repeated.",
|
||||
v => ((List<string>)TestList).AddRange(TestNameParser.Parse(RequiredValue(v, "--test"))));
|
||||
|
||||
this.Add("include=", "Test {CATEGORIES} to be included. May be a single category, a comma-separated list of categories or a category expression.",
|
||||
v => Include = RequiredValue(v, "--include"));
|
||||
|
||||
this.Add("exclude=", "Test {CATEGORIES} to be excluded. May be a single category, a comma-separated list of categories or a category expression.",
|
||||
v => Exclude = RequiredValue(v, "--exclude"));
|
||||
|
||||
this.Add("config=", "{NAME} of a project configuration to load (e.g.: Debug).",
|
||||
v => ActiveConfig = RequiredValue(v, "--config"));
|
||||
|
||||
// Where to Run Tests
|
||||
this.Add("process=", "{PROCESS} isolation for test assemblies.\nValues: Single, Separate, Multiple",
|
||||
v => ProcessModel = RequiredValue(v, "--process", "Single", "Separate", "Multiple"));
|
||||
|
||||
this.Add("domain=", "{DOMAIN} isolation for test assemblies.\nValues: None, Single, Multiple",
|
||||
v => DomainUsage = RequiredValue(v, "--domain", "None", "Single", "Multiple"));
|
||||
|
||||
// How to Run Tests
|
||||
this.Add("framework=", "{FRAMEWORK} type/version to use for tests.\nExamples: mono, net-3.5, v4.0, 2.0, mono-4.0",
|
||||
v => Framework = RequiredValue(v, "--framework"));
|
||||
|
||||
this.Add("timeout=", "Set timeout for each test case in {MILLISECONDS}.",
|
||||
v => defaultTimeout = RequiredInt(v, "--timeout"));
|
||||
|
||||
this.Add("seed=", "Set the random {SEED} used to generate test cases.",
|
||||
v => randomSeed = RequiredInt(v, "--seed"));
|
||||
|
||||
this.Add("workers=", "Specify the {NUMBER} of worker threads to be used in running tests.",
|
||||
v => numWorkers = RequiredInt(v, "--workers"));
|
||||
|
||||
this.Add("stoponerror", "Stop run immediately upon any test failure or error.",
|
||||
v => StopOnError = v != null);
|
||||
|
||||
this.Add("wait", "Wait for input before closing console window.",
|
||||
v => WaitBeforeExit = v != null);
|
||||
|
||||
this.Add("pause", "Pause before run to allow debugging.",
|
||||
v => PauseBeforeRun = v != null);
|
||||
|
||||
// Output Control
|
||||
this.Add("work=", "{PATH} of the directory to use for output files.",
|
||||
v => WorkDirectory = RequiredValue(v, "--work"));
|
||||
|
||||
this.Add("output|out=", "File {PATH} to contain text output from the tests.",
|
||||
v => OutFile = RequiredValue(v, "--output"));
|
||||
|
||||
this.Add("err=", "File {PATH} to contain error output from the tests.",
|
||||
v => ErrFile = RequiredValue(v, "--err"));
|
||||
|
||||
this.Add("result=", "An output {SPEC} for saving the test results.\nThis option may be repeated.",
|
||||
v => resultOutputSpecifications.Add(new OutputSpecification(RequiredValue(v, "--resultxml"))));
|
||||
|
||||
this.Add("explore:", "Display or save test info rather than running tests. Optionally provide an output {SPEC} for saving the test info. This option may be repeated.", v =>
|
||||
{
|
||||
Explore = true;
|
||||
if (v != null)
|
||||
ExploreOutputSpecifications.Add(new OutputSpecification(v));
|
||||
});
|
||||
|
||||
this.Add("noresult", "Don't save any test results.",
|
||||
v => noresult = v != null);
|
||||
|
||||
this.Add("labels=", "Specify whether to write test case names to the output. Values: Off, On, All",
|
||||
v => DisplayTestLabels = RequiredValue(v, "--labels", "Off", "On", "All"));
|
||||
|
||||
this.Add("trace=", "Set internal trace {LEVEL}.\nValues: Off, Error, Warning, Info, Verbose (Debug)",
|
||||
v => InternalTraceLevel = RequiredValue(v, "--trace", "Off", "Error", "Warning", "Info", "Verbose", "Debug"));
|
||||
|
||||
this.Add("noheader|noh", "Suppress display of program information at start of run.",
|
||||
v => NoHeader = v != null);
|
||||
|
||||
this.Add("nocolor|noc", "Displays console output without color.",
|
||||
v => NoColor = v != null);
|
||||
|
||||
this.Add("verbose|v", "Display additional information as the test runs.",
|
||||
v => Verbose = v != null);
|
||||
|
||||
this.Add("help|h", "Display this message and exit.",
|
||||
v => ShowHelp = v != null);
|
||||
|
||||
// Default
|
||||
this.Add("<>", v =>
|
||||
{
|
||||
if (v.StartsWith("-") || v.StartsWith("/") && Path.DirectorySeparatorChar != '/')
|
||||
ErrorMessages.Add("Invalid argument: " + v);
|
||||
else
|
||||
InputFiles.Add(v);
|
||||
});
|
||||
|
||||
if (args != null)
|
||||
this.Parse(args);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
// Action to Perform
|
||||
|
||||
public bool Explore { get; private set; }
|
||||
|
||||
public bool ShowHelp { get; private set; }
|
||||
|
||||
|
||||
// Select tests
|
||||
|
||||
private List<string> inputFiles = new List<string>();
|
||||
public IList<string> InputFiles { get { return inputFiles; } }
|
||||
|
||||
private List<string> testList = new List<string>();
|
||||
public IList<string> TestList { get { return testList; } }
|
||||
|
||||
public string Include { get; private set; }
|
||||
|
||||
public string Exclude { get; private set; }
|
||||
|
||||
public string ActiveConfig { get; private set; }
|
||||
|
||||
// Where to Run Tests
|
||||
|
||||
public string ProcessModel { get; private set; }
|
||||
|
||||
public string DomainUsage { get; private set; }
|
||||
|
||||
// How to Run Tests
|
||||
|
||||
public string Framework { get; private set; }
|
||||
|
||||
private int defaultTimeout = -1;
|
||||
public int DefaultTimeout { get { return defaultTimeout; } }
|
||||
|
||||
private int randomSeed = -1;
|
||||
public int RandomSeed { get { return randomSeed; } }
|
||||
|
||||
private int numWorkers = -1;
|
||||
public int NumWorkers { get { return numWorkers; } }
|
||||
|
||||
public bool StopOnError { get; private set; }
|
||||
|
||||
public bool WaitBeforeExit { get; private set; }
|
||||
|
||||
public bool PauseBeforeRun { get; private set; }
|
||||
|
||||
// Output Control
|
||||
|
||||
public bool NoHeader { get; private set; }
|
||||
|
||||
public bool NoColor { get; private set; }
|
||||
|
||||
public bool Verbose { get; private set; }
|
||||
|
||||
public string OutFile { get; private set; }
|
||||
|
||||
public string ErrFile { get; private set; }
|
||||
|
||||
public string DisplayTestLabels { get; private set; }
|
||||
|
||||
public string WorkDirectory { get; private set; }
|
||||
|
||||
public string InternalTraceLevel { get; private set; }
|
||||
|
||||
private List<OutputSpecification> resultOutputSpecifications = new List<OutputSpecification>();
|
||||
public IList<OutputSpecification> ResultOutputSpecifications
|
||||
{
|
||||
get
|
||||
{
|
||||
if (noresult)
|
||||
return new OutputSpecification[0];
|
||||
|
||||
if (resultOutputSpecifications.Count == 0)
|
||||
resultOutputSpecifications.Add(new OutputSpecification("TestResult.xml"));
|
||||
|
||||
return resultOutputSpecifications;
|
||||
}
|
||||
}
|
||||
|
||||
private List<OutputSpecification> exploreOutputSpecifications = new List<OutputSpecification>();
|
||||
public IList<OutputSpecification> ExploreOutputSpecifications { get { return exploreOutputSpecifications; } }
|
||||
|
||||
// Error Processing
|
||||
|
||||
public List<string> errorMessages = new List<string>();
|
||||
public IList<string> ErrorMessages { get { return errorMessages; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
if (!validated)
|
||||
{
|
||||
// Additional Checks here
|
||||
|
||||
validated = true;
|
||||
}
|
||||
|
||||
return ErrorMessages.Count == 0;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private string RequiredValue(string val, string option, params string[] validValues)
|
||||
{
|
||||
if (val == null || val == string.Empty)
|
||||
ErrorMessages.Add("Missing required value for option '" + option + "'.");
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
if (validValues != null && validValues.Length > 0)
|
||||
{
|
||||
isValid = false;
|
||||
|
||||
foreach (string valid in validValues)
|
||||
if (string.Compare(valid, val, true) == 0)
|
||||
isValid = true;
|
||||
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
ErrorMessages.Add(string.Format("The value '{0}' is not valid for option '{1}'.", val, option));
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
private int RequiredInt(string val, string option)
|
||||
{
|
||||
// We have to return something even though the value will
|
||||
// be ignored if an error is reported. The -1 value seems
|
||||
// like a safe bet in case it isn't ignored due to a bug.
|
||||
int result = -1;
|
||||
|
||||
if (val == null || val == string.Empty)
|
||||
ErrorMessages.Add("Missing required value for option '" + option + "'.");
|
||||
else
|
||||
{
|
||||
int r;
|
||||
if (int.TryParse(val, out r))
|
||||
result = r;
|
||||
else
|
||||
ErrorMessages.Add("An int value was exprected for option '{0}' but a value of '{1}' was used");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,104 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
public class OutputManager
|
||||
{
|
||||
private XmlNode result;
|
||||
private string workDirectory;
|
||||
|
||||
public OutputManager(XmlNode result, string workDirectory)
|
||||
{
|
||||
this.result = result;
|
||||
this.workDirectory = workDirectory;
|
||||
}
|
||||
|
||||
public void WriteResultFile(OutputSpecification spec, DateTime startTime)
|
||||
{
|
||||
string outputPath = Path.Combine(workDirectory, spec.OutputPath);
|
||||
IResultWriter outputWriter = null;
|
||||
|
||||
switch (spec.Format)
|
||||
{
|
||||
case "nunit3":
|
||||
outputWriter = new NUnit3XmlOutputWriter();
|
||||
break;
|
||||
|
||||
case "nunit2":
|
||||
outputWriter = new NUnit2XmlOutputWriter();
|
||||
break;
|
||||
|
||||
case "user":
|
||||
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
|
||||
string dir = Path.GetDirectoryName(uri.LocalPath);
|
||||
outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException(
|
||||
string.Format("Invalid XML output format '{0}'", spec.Format),
|
||||
"spec");
|
||||
}
|
||||
|
||||
outputWriter.WriteResultFile(result, outputPath);
|
||||
Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
|
||||
}
|
||||
|
||||
public void WriteTestFile(OutputSpecification spec)
|
||||
{
|
||||
string outputPath = Path.Combine(workDirectory, spec.OutputPath);
|
||||
IResultWriter outputWriter = null;
|
||||
|
||||
switch (spec.Format)
|
||||
{
|
||||
case "nunit3":
|
||||
outputWriter = new NUnit3XmlOutputWriter();
|
||||
break;
|
||||
|
||||
case "cases":
|
||||
outputWriter = new TestCaseOutputWriter();
|
||||
break;
|
||||
|
||||
case "user":
|
||||
Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
|
||||
string dir = Path.GetDirectoryName(uri.LocalPath);
|
||||
outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException(
|
||||
string.Format("Invalid XML output format '{0}'", spec.Format),
|
||||
"spec");
|
||||
}
|
||||
|
||||
outputWriter.WriteResultFile(result, outputPath);
|
||||
Console.WriteLine("Tests ({0}) saved as {1}", spec.Format, outputPath);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
public class OutputSpecification
|
||||
{
|
||||
#region Constructor
|
||||
|
||||
public OutputSpecification(string spec)
|
||||
{
|
||||
if (spec == null)
|
||||
throw new NullReferenceException("Output spec may not be null");
|
||||
|
||||
string[] parts = spec.Split(';');
|
||||
this.OutputPath = parts[0];
|
||||
|
||||
for (int i = 1; i < parts.Length; i++)
|
||||
{
|
||||
string[] opt = parts[i].Split('=');
|
||||
|
||||
if (opt.Length != 2)
|
||||
throw new ArgumentException();
|
||||
|
||||
switch (opt[0].Trim())
|
||||
{
|
||||
case "format":
|
||||
string fmt = opt[1].Trim();
|
||||
|
||||
if (this.Format != null && this.Format != fmt)
|
||||
throw new ArgumentException(
|
||||
string.Format("Conflicting format options: {0}", spec));
|
||||
|
||||
this.Format = fmt;
|
||||
break;
|
||||
|
||||
case "transform":
|
||||
string val = opt[1].Trim();
|
||||
|
||||
if (this.Transform != null && this.Transform != val)
|
||||
throw new ArgumentException(
|
||||
string.Format("Conflicting transform options: {0}", spec));
|
||||
|
||||
if (this.Format != null && this.Format != "user")
|
||||
throw new ArgumentException(
|
||||
string.Format("Conflicting format options: {0}", spec));
|
||||
|
||||
this.Format = "user";
|
||||
this.Transform = opt[1].Trim();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Format == null)
|
||||
Format = "nunit3";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public string OutputPath { get; private set; }
|
||||
|
||||
public string Format { get; private set; }
|
||||
|
||||
public string Transform { get; private set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,340 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Utilities;
|
||||
|
||||
public class NUnit2XmlOutputWriter : IResultWriter
|
||||
{
|
||||
private XmlWriter xmlWriter;
|
||||
|
||||
private static Dictionary<string, string> resultStates = new Dictionary<string, string>();
|
||||
|
||||
static NUnit2XmlOutputWriter()
|
||||
{
|
||||
resultStates["Passed"] = "Success";
|
||||
resultStates["Failed"] = "Failure";
|
||||
resultStates["Failed:Error"] = "Error";
|
||||
resultStates["Failed:Cancelled"] = "Cancelled";
|
||||
resultStates["Inconclusive"] = "Inconclusive";
|
||||
resultStates["Skipped"] = "Skipped";
|
||||
resultStates["Skipped:Ignored"] = "Ignored";
|
||||
resultStates["Skipped:Invalid"] = "NotRunnable";
|
||||
}
|
||||
|
||||
public void WriteResultFile(XmlNode result, string outputPath)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
|
||||
{
|
||||
WriteResultFile(result, writer);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteResultFile(XmlNode result, TextWriter writer)
|
||||
{
|
||||
using (XmlTextWriter xmlWriter = new XmlTextWriter(writer))
|
||||
{
|
||||
xmlWriter.Formatting = Formatting.Indented;
|
||||
WriteXmlOutput(result, xmlWriter);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteXmlOutput(XmlNode result, XmlWriter xmlWriter)
|
||||
{
|
||||
this.xmlWriter = xmlWriter;
|
||||
|
||||
InitializeXmlFile(result);
|
||||
|
||||
foreach (XmlNode child in result.ChildNodes)
|
||||
if (child.Name.StartsWith("test-"))
|
||||
WriteResultElement(child);
|
||||
|
||||
TerminateXmlFile();
|
||||
}
|
||||
|
||||
private void InitializeXmlFile(XmlNode result)
|
||||
{
|
||||
ResultSummary summaryResults = new ResultSummary(result);
|
||||
|
||||
xmlWriter.WriteStartDocument(false);
|
||||
xmlWriter.WriteComment("This file represents the results of running a test suite");
|
||||
|
||||
xmlWriter.WriteStartElement("test-results");
|
||||
|
||||
xmlWriter.WriteAttributeString("name", result.GetAttribute("fullname"));
|
||||
xmlWriter.WriteAttributeString("total", summaryResults.TestsRun.ToString());
|
||||
xmlWriter.WriteAttributeString("errors", summaryResults.Errors.ToString());
|
||||
xmlWriter.WriteAttributeString("failures", summaryResults.Failures.ToString());
|
||||
xmlWriter.WriteAttributeString("not-run", summaryResults.TestsNotRun.ToString());
|
||||
xmlWriter.WriteAttributeString("inconclusive", summaryResults.Inconclusive.ToString());
|
||||
xmlWriter.WriteAttributeString("ignored", summaryResults.Ignored.ToString());
|
||||
xmlWriter.WriteAttributeString("skipped", summaryResults.Skipped.ToString());
|
||||
xmlWriter.WriteAttributeString("invalid", summaryResults.NotRunnable.ToString());
|
||||
|
||||
DateTime start = result.GetAttribute("start-time", DateTime.UtcNow);
|
||||
xmlWriter.WriteAttributeString("date", start.ToString("yyyy-MM-dd"));
|
||||
xmlWriter.WriteAttributeString("time", start.ToString("HH:mm:ss"));
|
||||
WriteEnvironment();
|
||||
WriteCultureInfo();
|
||||
}
|
||||
|
||||
private void WriteCultureInfo()
|
||||
{
|
||||
xmlWriter.WriteStartElement("culture-info");
|
||||
xmlWriter.WriteAttributeString("current-culture",
|
||||
CultureInfo.CurrentCulture.ToString());
|
||||
xmlWriter.WriteAttributeString("current-uiculture",
|
||||
CultureInfo.CurrentUICulture.ToString());
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WriteEnvironment()
|
||||
{
|
||||
xmlWriter.WriteStartElement("environment");
|
||||
xmlWriter.WriteAttributeString("nunit-version",
|
||||
Assembly.GetExecutingAssembly().GetName().Version.ToString());
|
||||
xmlWriter.WriteAttributeString("clr-version",
|
||||
Environment.Version.ToString());
|
||||
xmlWriter.WriteAttributeString("os-version",
|
||||
Environment.OSVersion.ToString());
|
||||
xmlWriter.WriteAttributeString("platform",
|
||||
Environment.OSVersion.Platform.ToString());
|
||||
xmlWriter.WriteAttributeString("cwd",
|
||||
Environment.CurrentDirectory);
|
||||
xmlWriter.WriteAttributeString("machine-name",
|
||||
Environment.MachineName);
|
||||
xmlWriter.WriteAttributeString("user",
|
||||
Environment.UserName);
|
||||
xmlWriter.WriteAttributeString("user-domain",
|
||||
Environment.UserDomainName);
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WriteResultElement(XmlNode result)
|
||||
{
|
||||
StartTestElement(result);
|
||||
|
||||
var categories = result.SelectSingleNode("categories");
|
||||
if (categories != null)
|
||||
WriteCategoriesElement(categories);
|
||||
|
||||
var properties = result.SelectSingleNode("properties");
|
||||
if (properties != null)
|
||||
WritePropertiesElement(properties);
|
||||
|
||||
var message = result.SelectSingleNode("reason/message");
|
||||
if (message != null)
|
||||
WriteReasonElement(message.InnerText);
|
||||
|
||||
message = result.SelectSingleNode("failure/message");
|
||||
var stackTrace = result.SelectSingleNode("failure/stack-trace");
|
||||
if (message != null)
|
||||
WriteFailureElement(message.InnerText, stackTrace == null ? null : stackTrace.InnerText);
|
||||
|
||||
if (result.Name != "test-case")
|
||||
WriteChildResults(result);
|
||||
|
||||
xmlWriter.WriteEndElement(); // test element
|
||||
}
|
||||
|
||||
private void TerminateXmlFile()
|
||||
{
|
||||
xmlWriter.WriteEndElement(); // test-results
|
||||
xmlWriter.WriteEndDocument();
|
||||
xmlWriter.Flush();
|
||||
xmlWriter.Close();
|
||||
}
|
||||
|
||||
|
||||
#region Element Creation Helpers
|
||||
|
||||
private void StartTestElement(XmlNode result)
|
||||
{
|
||||
if (result.Name == "test-case")
|
||||
{
|
||||
xmlWriter.WriteStartElement("test-case");
|
||||
xmlWriter.WriteAttributeString("name", result.GetAttribute("name"));
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlWriter.WriteStartElement("test-suite");
|
||||
xmlWriter.WriteAttributeString("type", result.GetAttribute("type"));
|
||||
string nameAttr = result.Name == "test-assembly" || result.Name == "test-project" ? "fullname" : "name";
|
||||
xmlWriter.WriteAttributeString("name", result.GetAttribute(nameAttr));
|
||||
}
|
||||
|
||||
string description = result.GetAttribute("description");
|
||||
if (description != null)
|
||||
xmlWriter.WriteAttributeString("description", description);
|
||||
|
||||
string resultState = result.GetAttribute("result");
|
||||
string label = result.GetAttribute("label");
|
||||
string executed = resultState == "Skipped" ? "False" : "True";
|
||||
string success = resultState == "Passed" ? "True" : "False";
|
||||
|
||||
double duration = result.GetAttribute("duration", 0.0);
|
||||
string asserts = result.GetAttribute("asserts");
|
||||
|
||||
if (label != null && label != string.Empty)
|
||||
resultState += ":" + label;
|
||||
|
||||
xmlWriter.WriteAttributeString("executed", executed);
|
||||
xmlWriter.WriteAttributeString("result", resultStates[resultState]);
|
||||
|
||||
if (executed == "True")
|
||||
{
|
||||
xmlWriter.WriteAttributeString("success", success);
|
||||
xmlWriter.WriteAttributeString("time", duration.ToString("0.000"));
|
||||
xmlWriter.WriteAttributeString("asserts", asserts);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteCategoriesElement(XmlNode categories)
|
||||
{
|
||||
xmlWriter.WriteStartElement("categories");
|
||||
var items = categories.SelectNodes("category");
|
||||
foreach (XmlNode item in items)
|
||||
{
|
||||
xmlWriter.WriteStartElement("category");
|
||||
xmlWriter.WriteAttributeString("name", item.GetAttribute("name"));
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WritePropertiesElement(XmlNode properties)
|
||||
{
|
||||
xmlWriter.WriteStartElement("properties");
|
||||
|
||||
var items = properties.SelectNodes("property");
|
||||
foreach (XmlNode item in items)
|
||||
{
|
||||
xmlWriter.WriteStartElement("property");
|
||||
xmlWriter.WriteAttributeString("name", item.GetAttribute("name"));
|
||||
xmlWriter.WriteAttributeString("value", item.GetAttribute("value"));
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WriteReasonElement(string message)
|
||||
{
|
||||
xmlWriter.WriteStartElement("reason");
|
||||
xmlWriter.WriteStartElement("message");
|
||||
xmlWriter.WriteCData(message);
|
||||
xmlWriter.WriteEndElement();
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WriteFailureElement(string message, string stackTrace)
|
||||
{
|
||||
xmlWriter.WriteStartElement("failure");
|
||||
xmlWriter.WriteStartElement("message");
|
||||
WriteCData(message);
|
||||
xmlWriter.WriteEndElement();
|
||||
xmlWriter.WriteStartElement("stack-trace");
|
||||
if (stackTrace != null)
|
||||
WriteCData(stackTrace);
|
||||
xmlWriter.WriteEndElement();
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
|
||||
private void WriteChildResults(XmlNode result)
|
||||
{
|
||||
xmlWriter.WriteStartElement("results");
|
||||
|
||||
foreach (XmlNode childResult in result.ChildNodes)
|
||||
if (childResult.Name.StartsWith("test-"))
|
||||
WriteResultElement(childResult);
|
||||
|
||||
xmlWriter.WriteEndElement();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Output Helpers
|
||||
/// <summary>
|
||||
/// Makes string safe for xml parsing, replacing control chars with '?'
|
||||
/// </summary>
|
||||
/// <param name="encodedString">string to make safe</param>
|
||||
/// <returns>xml safe string</returns>
|
||||
private static string CharacterSafeString(string encodedString)
|
||||
{
|
||||
/*The default code page for the system will be used.
|
||||
Since all code pages use the same lower 128 bytes, this should be sufficient
|
||||
for finding uprintable control characters that make the xslt processor error.
|
||||
We use characters encoded by the default code page to avoid mistaking bytes as
|
||||
individual characters on non-latin code pages.*/
|
||||
char[] encodedChars = System.Text.Encoding.Default.GetChars(System.Text.Encoding.Default.GetBytes(encodedString));
|
||||
|
||||
System.Collections.ArrayList pos = new System.Collections.ArrayList();
|
||||
for (int x = 0; x < encodedChars.Length; x++)
|
||||
{
|
||||
char currentChar = encodedChars[x];
|
||||
//unprintable characters are below 0x20 in Unicode tables
|
||||
//some control characters are acceptable. (carriage return 0x0D, line feed 0x0A, horizontal tab 0x09)
|
||||
if (currentChar < 32 && (currentChar != 9 && currentChar != 10 && currentChar != 13))
|
||||
{
|
||||
//save the array index for later replacement.
|
||||
pos.Add(x);
|
||||
}
|
||||
}
|
||||
foreach (int index in pos)
|
||||
{
|
||||
encodedChars[index] = '?';//replace unprintable control characters with ?(3F)
|
||||
}
|
||||
return System.Text.Encoding.Default.GetString(System.Text.Encoding.Default.GetBytes(encodedChars));
|
||||
}
|
||||
|
||||
private void WriteCData(string text)
|
||||
{
|
||||
int start = 0;
|
||||
while (true)
|
||||
{
|
||||
int illegal = text.IndexOf("]]>", start);
|
||||
if (illegal < 0)
|
||||
break;
|
||||
xmlWriter.WriteCData(text.Substring(start, illegal - start + 2));
|
||||
start = illegal + 2;
|
||||
if (start >= text.Length)
|
||||
return;
|
||||
}
|
||||
|
||||
if (start > 0)
|
||||
xmlWriter.WriteCData(text.Substring(start));
|
||||
else
|
||||
xmlWriter.WriteCData(text);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// NUnit3XmlOutputWriter is responsible for writing the results
|
||||
/// of a test to a file in NUnit 3.0 format.
|
||||
/// </summary>
|
||||
public class NUnit3XmlOutputWriter : IResultWriter
|
||||
{
|
||||
public void WriteResultFile(XmlNode resultNode, string outputPath)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
|
||||
{
|
||||
WriteResultFile(resultNode, writer);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteResultFile(XmlNode resultNode, TextWriter writer)
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
settings.Indent = true;
|
||||
|
||||
using (XmlWriter xmlWriter = XmlWriter.Create(writer, settings))
|
||||
{
|
||||
xmlWriter.WriteStartDocument(false);
|
||||
resultNode.WriteTo(xmlWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
public class TestCaseOutputWriter : IResultWriter
|
||||
{
|
||||
public void WriteResultFile(XmlNode resultNode, string outputPath)
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(outputPath, false, Encoding.UTF8))
|
||||
{
|
||||
WriteResultFile(resultNode, writer);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteResultFile(XmlNode resultNode, TextWriter writer)
|
||||
{
|
||||
foreach (XmlNode node in resultNode.SelectNodes("//test-case"))
|
||||
writer.WriteLine(node.Attributes["fullname"].Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
public class XmlTransformOutputWriter : IResultWriter
|
||||
{
|
||||
private string xsltFile;
|
||||
private XslCompiledTransform transform = new XslCompiledTransform();
|
||||
|
||||
public XmlTransformOutputWriter(string xsltFile)
|
||||
{
|
||||
this.xsltFile = xsltFile;
|
||||
transform.Load(xsltFile);
|
||||
}
|
||||
|
||||
public void WriteResultFile(XmlNode result, TextWriter writer)
|
||||
{
|
||||
using (XmlTextWriter xmlWriter = new XmlTextWriter(writer))
|
||||
{
|
||||
xmlWriter.Formatting = Formatting.Indented;
|
||||
transform.Transform(result, xmlWriter);
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteResultFile(XmlNode result, string outputPath)
|
||||
{
|
||||
using (XmlTextWriter xmlWriter = new XmlTextWriter(outputPath, Encoding.Default))
|
||||
{
|
||||
xmlWriter.Formatting = Formatting.Indented;
|
||||
transform.Transform(result, xmlWriter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,260 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Mono.Options;
|
||||
using NUnit.Engine;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Options;
|
||||
using Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides the entry point for the console runner.
|
||||
/// </summary>
|
||||
public class Program
|
||||
{
|
||||
//static Logger log = InternalTrace.GetLogger(typeof(Runner));
|
||||
|
||||
[STAThread]
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
ConsoleOptions options = new ConsoleOptions();
|
||||
|
||||
try
|
||||
{
|
||||
options.Parse(args);
|
||||
}
|
||||
catch (OptionException ex)
|
||||
{
|
||||
WriteHeader();
|
||||
ColorConsole.WriteLine(ColorStyle.Error, string.Format(ex.Message, ex.OptionName));
|
||||
return ConsoleRunner.INVALID_ARG;
|
||||
}
|
||||
|
||||
ColorConsole.Enabled = !options.NoColor;
|
||||
|
||||
// Create SettingsService early so we know the trace level right at the start
|
||||
//SettingsService settingsService = new SettingsService();
|
||||
//InternalTraceLevel level = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default);
|
||||
//if (options.trace != InternalTraceLevel.Default)
|
||||
// level = options.trace;
|
||||
|
||||
//InternalTrace.Initialize("nunit-console_%p.log", level);
|
||||
|
||||
//log.Info("NUnit-console.exe starting");
|
||||
try
|
||||
{
|
||||
if (options.PauseBeforeRun)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Warning, "Press any key to continue . . .");
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
|
||||
if (!options.NoHeader)
|
||||
WriteHeader();
|
||||
|
||||
if (options.ShowHelp)
|
||||
{
|
||||
WriteHelpText(options);
|
||||
return ConsoleRunner.OK;
|
||||
}
|
||||
|
||||
if (!options.Validate())
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Error))
|
||||
{
|
||||
foreach (string message in options.ErrorMessages)
|
||||
Console.Error.WriteLine(message);
|
||||
}
|
||||
|
||||
return ConsoleRunner.INVALID_ARG;
|
||||
}
|
||||
|
||||
if (options.InputFiles.Count == 0)
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Error))
|
||||
Console.Error.WriteLine("Error: no inputs specified");
|
||||
return ConsoleRunner.OK;
|
||||
}
|
||||
|
||||
// TODO: Move this to engine
|
||||
foreach (string file in options.InputFiles)
|
||||
{
|
||||
//if (!Services.ProjectService.CanLoadProject(file) && !PathUtils.IsAssemblyFileType(file))
|
||||
string ext = Path.GetExtension(file);
|
||||
if (ext != ".dll" && ext != ".exe" && ext != ".nunit")
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Warning, "File type not known: " + file);
|
||||
return ConsoleRunner.INVALID_ARG;
|
||||
}
|
||||
}
|
||||
|
||||
using (ITestEngine engine = TestEngineActivator.CreateInstance())
|
||||
{
|
||||
if (options.WorkDirectory != null)
|
||||
engine.WorkDirectory = options.WorkDirectory;
|
||||
|
||||
if (options.InternalTraceLevel != null)
|
||||
engine.InternalTraceLevel = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel);
|
||||
|
||||
try
|
||||
{
|
||||
return new ConsoleRunner(engine, options).Execute();
|
||||
}
|
||||
catch (NUnitEngineException ex)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Error, ex.Message);
|
||||
return ConsoleRunner.INVALID_ARG;
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Error, ex.Message);
|
||||
#if DEBUG
|
||||
ColorConsole.WriteLine(ColorStyle.Error, ex.StackTrace);
|
||||
#endif
|
||||
return ConsoleRunner.FILE_NOT_FOUND;
|
||||
}
|
||||
catch (DirectoryNotFoundException ex)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Error, ex.Message);
|
||||
return ConsoleRunner.FILE_NOT_FOUND;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Error, ex.Message);
|
||||
return ConsoleRunner.UNEXPECTED_ERROR;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (options.WaitBeforeExit)
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Warning))
|
||||
{
|
||||
Console.Out.WriteLine("\nPress any key to continue . . .");
|
||||
Console.ReadKey(true);
|
||||
}
|
||||
}
|
||||
|
||||
// log.Info( "NUnit-console.exe terminating" );
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
|
||||
private static void WriteHeader()
|
||||
{
|
||||
Assembly executingAssembly = Assembly.GetExecutingAssembly();
|
||||
string versionText = executingAssembly.GetName().Version.ToString(3);
|
||||
|
||||
string programName = "NUnit Console Runner";
|
||||
string copyrightText = "Copyright (C) 2014 Charlie Poole.\r\nAll Rights Reserved.";
|
||||
string configText = String.Empty;
|
||||
|
||||
object[] attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
|
||||
if (attrs.Length > 0)
|
||||
programName = ((AssemblyTitleAttribute)attrs[0]).Title;
|
||||
|
||||
attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
||||
if ( attrs.Length > 0 )
|
||||
copyrightText = ((AssemblyCopyrightAttribute)attrs[0]).Copyright;
|
||||
|
||||
attrs = executingAssembly.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false);
|
||||
if ( attrs.Length > 0 )
|
||||
{
|
||||
string configuration = ( ( AssemblyConfigurationAttribute )attrs[0] ).Configuration;
|
||||
if ( !String.IsNullOrEmpty( configuration ) )
|
||||
{
|
||||
configText = string.Format( "({0})", ( ( AssemblyConfigurationAttribute )attrs[0] ).Configuration );
|
||||
}
|
||||
}
|
||||
|
||||
ColorConsole.WriteLine(ColorStyle.Header, string.Format( "{0} {1} {2}", programName, versionText, configText ));
|
||||
ColorConsole.WriteLine(ColorStyle.SubHeader, copyrightText);
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Runtime Environment");
|
||||
ColorConsole.WriteLabel(" OS Version: ", Environment.OSVersion.ToString(), true);
|
||||
ColorConsole.WriteLabel(" CLR Version: ", Environment.Version.ToString(), true);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private static void WriteHelpText(ConsoleOptions options)
|
||||
{
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.Header, "NUNIT-CONSOLE [inputfiles] [options]");
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.Default, "Runs a set of NUnit tests from the console.");
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "InputFiles:");
|
||||
ColorConsole.WriteLine(ColorStyle.Default, " One or more assemblies or test projects of a recognized type.");
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Options:");
|
||||
using (new ColorConsole(ColorStyle.Default))
|
||||
{
|
||||
options.WriteOptionDescriptions(Console.Out);
|
||||
}
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Description:");
|
||||
using (new ColorConsole(ColorStyle.Default))
|
||||
{
|
||||
Console.WriteLine(" By default, this command runs the tests contained in the");
|
||||
Console.WriteLine(" assemblies and projects specified. If the --explore option");
|
||||
Console.WriteLine(" is used, no tests are executed but a description of the tests");
|
||||
Console.WriteLine(" is saved in the specified or default format.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" Several options that specify processing of XML output take");
|
||||
Console.WriteLine(" an output specification as a value. A SPEC may take one of");
|
||||
Console.WriteLine(" the following forms:");
|
||||
Console.WriteLine(" --OPTION:filename");
|
||||
Console.WriteLine(" --OPTION:filename;format=formatname");
|
||||
Console.WriteLine(" --OPTION:filename;transform=xsltfile");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" The --result option may use any of the following formats:");
|
||||
Console.WriteLine(" nunit3 - the native XML format for NUnit 3.0");
|
||||
Console.WriteLine(" nunit2 - legacy XML format used by earlier releases of NUnit");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" The --explore option may use any of the following formats:");
|
||||
Console.WriteLine(" nunit3 - the native XML format for NUnit 3.0");
|
||||
Console.WriteLine(" cases - a text file listing the full names of all test cases.");
|
||||
Console.WriteLine(" If --explore is used without any specification following, a list of");
|
||||
Console.WriteLine(" test cases is output to the console.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" If none of the options {--result, --explore, --noxml} is used,");
|
||||
Console.WriteLine(" NUnit saves the results to TestResult.xml in nunit3 format");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" Any transforms provided must handle input in the native nunit3 format.");
|
||||
Console.WriteLine();
|
||||
//Console.WriteLine("Options that take values may use an equal sign, a colon");
|
||||
//Console.WriteLine("or a space to separate the option from its value.");
|
||||
//Console.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NUnit Console Runner")]
|
||||
[assembly: AssemblyDescription("The console command-line runner for NUnit")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b2dfdf79-289b-4b45-ab40-8d461b7d56d7")]
|
|
@ -0,0 +1,248 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2009 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Options;
|
||||
using Utilities;
|
||||
|
||||
public class ResultReporter
|
||||
{
|
||||
XmlNode result;
|
||||
string testRunResult;
|
||||
ConsoleOptions options;
|
||||
ResultSummary summary;
|
||||
|
||||
int reportIndex = 0;
|
||||
|
||||
public ResultReporter(XmlNode result, ConsoleOptions options)
|
||||
{
|
||||
this.result = result;
|
||||
this.testRunResult = result.GetAttribute("result");
|
||||
this.options = options;
|
||||
this.summary = new ResultSummary(result);
|
||||
}
|
||||
|
||||
public ResultSummary Summary
|
||||
{
|
||||
get { return summary; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports the results to the console
|
||||
/// </summary>
|
||||
public void ReportResults()
|
||||
{
|
||||
if (options.StopOnError && summary.ErrorsAndFailures > 0)
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Failure, "Execution terminated after first error");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
WriteSummaryReport();
|
||||
|
||||
if (ListAssembliesWithNoTests(result) > 0)
|
||||
Console.WriteLine();
|
||||
|
||||
if (testRunResult == "Failed")
|
||||
WriteErrorsAndFailuresReport();
|
||||
|
||||
if (summary.TestsNotRun > 0)
|
||||
WriteNotRunReport();
|
||||
}
|
||||
|
||||
private void WriteSummaryReport()
|
||||
{
|
||||
ColorStyle overall = testRunResult == "Passed"
|
||||
? ColorStyle.Pass
|
||||
: ( testRunResult == "Failed" ? ColorStyle.Failure : ColorStyle.Warning );
|
||||
Console.WriteLine();
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Test Run Summary");
|
||||
ColorConsole.WriteLabel(" Overall result: ", testRunResult, overall, true);
|
||||
|
||||
ColorConsole.WriteLabel(" Tests run: ", summary.TestsRun.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Errors: ", summary.Errors.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Failures: ", summary.Failures.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Inconclusive: ", summary.Inconclusive.ToString(CultureInfo.CurrentUICulture), true);
|
||||
|
||||
ColorConsole.WriteLabel(" Not run: ", summary.TestsNotRun.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Invalid: ", summary.NotRunnable.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Ignored: ", summary.Ignored.ToString(CultureInfo.CurrentUICulture), false);
|
||||
ColorConsole.WriteLabel(", Skipped: ", summary.Skipped.ToString(CultureInfo.CurrentUICulture), true);
|
||||
|
||||
ColorConsole.WriteLabel(" Start time: ", summary.StartTime.ToString("u"), true);
|
||||
ColorConsole.WriteLabel(" End time: ", summary.EndTime.ToString("u"), true);
|
||||
ColorConsole.WriteLabel(" Duration: ", string.Format("{0} seconds", summary.Duration.ToString("0.000")), true);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private int ListAssembliesWithNoTests(XmlNode result)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
switch (result.Name)
|
||||
{
|
||||
case "test-run":
|
||||
foreach (XmlNode child in result.ChildNodes)
|
||||
count += ListAssembliesWithNoTests(child);
|
||||
break;
|
||||
|
||||
case "test-suite":
|
||||
if (result.GetAttribute("type") == "Assembly")
|
||||
{
|
||||
if (result.GetAttribute("total") == "0")
|
||||
{
|
||||
ColorConsole.WriteLine(ColorStyle.Warning, "Warning: No tests found in " + result.GetAttribute("name"));
|
||||
}
|
||||
count++;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (XmlNode child in result.ChildNodes)
|
||||
count += ListAssembliesWithNoTests(child);
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
private void WriteErrorsAndFailuresReport()
|
||||
{
|
||||
this.reportIndex = 0;
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Errors and Failures");
|
||||
WriteErrorsAndFailures(result);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private void WriteErrorsAndFailures(XmlNode result)
|
||||
{
|
||||
switch(result.Name)
|
||||
{
|
||||
case "test-case":
|
||||
string resultState = result.GetAttribute("result");
|
||||
if (resultState == "Failed")
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Failure))
|
||||
WriteSingleResult(result);
|
||||
}
|
||||
else if (resultState == "Error")
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Error))
|
||||
WriteSingleResult(result);
|
||||
}
|
||||
else if (resultState == "Cancelled")
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Warning))
|
||||
WriteSingleResult(result);
|
||||
}
|
||||
return;
|
||||
|
||||
case "test-run":
|
||||
break;
|
||||
|
||||
case "test-suite":
|
||||
string resultType = result.GetAttribute("type");
|
||||
if (resultType == "Theory")
|
||||
{
|
||||
resultState = result.GetAttribute("result");
|
||||
if (resultState == "Failed")
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Failure))
|
||||
WriteSingleResult(result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Display failures in fixture setup or teardown
|
||||
foreach (XmlNode childResult in result.ChildNodes)
|
||||
WriteErrorsAndFailures(childResult);
|
||||
}
|
||||
|
||||
|
||||
public void WriteNotRunReport()
|
||||
{
|
||||
this.reportIndex = 0;
|
||||
ColorConsole.WriteLine(ColorStyle.SectionHeader, "Tests Not Run");
|
||||
WriteNotRunResults(result);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private void WriteNotRunResults(XmlNode result)
|
||||
{
|
||||
if (result.Name == "test-case")
|
||||
{
|
||||
string resultState = result.GetAttribute("result");
|
||||
if (resultState == "Skipped" || resultState == "Ignored" || resultState == "NotRunnable")
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Warning))
|
||||
WriteSingleResult(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (XmlNode childResult in result.ChildNodes)
|
||||
WriteNotRunResults(childResult);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteSingleResult(XmlNode result)
|
||||
{
|
||||
string status = result.GetAttribute("label");
|
||||
if (status == null)
|
||||
status = result.GetAttribute("result");
|
||||
string fullName = result.GetAttribute("fullname");
|
||||
|
||||
Console.WriteLine("{0}) {1} : {2}", ++reportIndex, status, fullName);
|
||||
|
||||
XmlNode failureNode = result.SelectSingleNode("failure");
|
||||
if (failureNode != null)
|
||||
{
|
||||
XmlNode message = failureNode.SelectSingleNode("message");
|
||||
XmlNode stacktrace = failureNode.SelectSingleNode("stack-trace");
|
||||
|
||||
if (message != null)
|
||||
Console.WriteLine(message.InnerText);
|
||||
|
||||
if (stacktrace != null)
|
||||
Console.WriteLine(status == "Failed"
|
||||
? StackTraceFilter.Filter(stacktrace.InnerText)
|
||||
: stacktrace.InnerText + Environment.NewLine);
|
||||
//Console.WriteLine(stacktrace.InnerText + Environment.NewLine);
|
||||
}
|
||||
|
||||
XmlNode reasonNode = result.SelectSingleNode("reason");
|
||||
if (reasonNode != null)
|
||||
{
|
||||
XmlNode message = reasonNode.SelectSingleNode("message");
|
||||
|
||||
if (message != null)
|
||||
Console.WriteLine(message.InnerText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2007 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for ResultSummary.
|
||||
/// </summary>
|
||||
public class ResultSummary
|
||||
{
|
||||
private int resultCount = 0;
|
||||
private int testsRun = 0;
|
||||
private int failureCount = 0;
|
||||
private int errorCount = 0;
|
||||
private int successCount = 0;
|
||||
private int inconclusiveCount = 0;
|
||||
private int skipCount = 0;
|
||||
private int ignoreCount = 0;
|
||||
private int notRunnable = 0;
|
||||
|
||||
private DateTime startTime = DateTime.MinValue;
|
||||
private DateTime endTime = DateTime.MaxValue;
|
||||
private double duration = 0.0d;
|
||||
private string name;
|
||||
|
||||
public ResultSummary() { }
|
||||
|
||||
public ResultSummary(XmlNode result)
|
||||
{
|
||||
if (result.Name != "test-run")
|
||||
throw new InvalidOperationException("Expected <test-run> as top-level element but was <" + result.Name + ">");
|
||||
|
||||
name = result.GetAttribute("name");
|
||||
duration = result.GetAttribute("duration", 0.0);
|
||||
startTime = result.GetAttribute("start-time", DateTime.MinValue);
|
||||
endTime = result.GetAttribute("end-time", DateTime.MaxValue);
|
||||
|
||||
Summarize(result);
|
||||
}
|
||||
|
||||
private void Summarize(XmlNode node)
|
||||
{
|
||||
switch (node.Name)
|
||||
{
|
||||
case "test-case":
|
||||
resultCount++;
|
||||
|
||||
string outcome = node.GetAttribute("result");
|
||||
string label = node.GetAttribute("label");
|
||||
if (label != null)
|
||||
outcome = label;
|
||||
|
||||
switch (outcome)
|
||||
{
|
||||
case "Passed":
|
||||
successCount++;
|
||||
testsRun++;
|
||||
break;
|
||||
case "Failed":
|
||||
failureCount++;
|
||||
testsRun++;
|
||||
break;
|
||||
case "Error":
|
||||
case "Cancelled":
|
||||
errorCount++;
|
||||
testsRun++;
|
||||
break;
|
||||
case "Inconclusive":
|
||||
inconclusiveCount++;
|
||||
testsRun++;
|
||||
break;
|
||||
case "NotRunnable":
|
||||
notRunnable++;
|
||||
//errorCount++;
|
||||
break;
|
||||
case "Ignored":
|
||||
ignoreCount++;
|
||||
break;
|
||||
case "Skipped":
|
||||
default:
|
||||
skipCount++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
//case "test-suite":
|
||||
//case "test-fixture":
|
||||
//case "method-group":
|
||||
default:
|
||||
foreach (XmlNode childResult in node.ChildNodes)
|
||||
Summarize(childResult);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public bool Success
|
||||
{
|
||||
get { return failureCount == 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases for which results
|
||||
/// have been summarized. Any tests excluded by use of
|
||||
/// Category or Explicit attributes are not counted.
|
||||
/// </summary>
|
||||
public int ResultCount
|
||||
{
|
||||
get { return resultCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases actually run, which
|
||||
/// is the same as ResultCount, less any Skipped, Ignored
|
||||
/// or NonRunnable tests.
|
||||
/// </summary>
|
||||
public int TestsRun
|
||||
{
|
||||
get { return testsRun; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of tests that passed
|
||||
/// </summary>
|
||||
public int Passed
|
||||
{
|
||||
get { return successCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases that had an error.
|
||||
/// </summary>
|
||||
public int Errors
|
||||
{
|
||||
get { return errorCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases that failed.
|
||||
/// </summary>
|
||||
public int Failures
|
||||
{
|
||||
get { return failureCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases that failed.
|
||||
/// </summary>
|
||||
public int Inconclusive
|
||||
{
|
||||
get { return inconclusiveCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases that were not runnable
|
||||
/// due to errors in the signature of the class or method.
|
||||
/// Such tests are also counted as Errors.
|
||||
/// </summary>
|
||||
public int NotRunnable
|
||||
{
|
||||
get { return notRunnable; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the number of test cases that were skipped.
|
||||
/// </summary>
|
||||
public int Skipped
|
||||
{
|
||||
get { return skipCount; }
|
||||
}
|
||||
|
||||
public int Ignored
|
||||
{
|
||||
get { return ignoreCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the start time of the test run.
|
||||
/// </summary>
|
||||
public DateTime StartTime
|
||||
{
|
||||
get { return startTime; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the end time of the test run.
|
||||
/// </summary>
|
||||
public DateTime EndTime
|
||||
{
|
||||
get { return endTime; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the duration of the test run.
|
||||
/// </summary>
|
||||
public double Duration
|
||||
{
|
||||
get { return duration; }
|
||||
}
|
||||
|
||||
public int TestsNotRun
|
||||
{
|
||||
get { return skipCount + ignoreCount + notRunnable; }
|
||||
}
|
||||
|
||||
public int ErrorsAndFailures
|
||||
{
|
||||
get { return errorCount + failureCount; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,218 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2007 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using NUnit.Engine;
|
||||
|
||||
namespace NUnit.ConsoleRunner
|
||||
{
|
||||
using Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// TestEventHandler processes events from the running
|
||||
/// test for the console runner.
|
||||
/// </summary>
|
||||
public class TestEventHandler : MarshalByRefObject, ITestEventListener
|
||||
{
|
||||
private int _testRunCount;
|
||||
private int _testIgnoreCount;
|
||||
private int _failureCount;
|
||||
private int _level;
|
||||
|
||||
private string _displayLabels;
|
||||
private TextWriter _outWriter;
|
||||
|
||||
private List<string> _messages = new List<string>();
|
||||
|
||||
|
||||
public TestEventHandler(TextWriter outWriter, string displayLabels)
|
||||
{
|
||||
_level = 0;
|
||||
_displayLabels = displayLabels;
|
||||
_outWriter = outWriter;
|
||||
}
|
||||
|
||||
#region ITestEventHandler Members
|
||||
|
||||
public void OnTestEvent(string report)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(report);
|
||||
XmlNode testEvent = doc.FirstChild;
|
||||
|
||||
switch (testEvent.Name)
|
||||
{
|
||||
case "start-test":
|
||||
TestStarted(testEvent);
|
||||
break;
|
||||
|
||||
case "start-suite":
|
||||
SuiteStarted(testEvent);
|
||||
break;
|
||||
|
||||
case "start-run":
|
||||
//RunStarted(testEvent);
|
||||
break;
|
||||
|
||||
case "test-case":
|
||||
TestFinished(testEvent);
|
||||
break;
|
||||
|
||||
case "test-suite":
|
||||
SuiteFinished(testEvent);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Individual Handlers
|
||||
|
||||
private void TestStarted(XmlNode startNode)
|
||||
{
|
||||
// Placeolder for TeamCity output
|
||||
}
|
||||
|
||||
public void SuiteStarted(XmlNode startNode)
|
||||
{
|
||||
if (_level++ == 0)
|
||||
{
|
||||
_testRunCount = 0;
|
||||
_testIgnoreCount = 0;
|
||||
_failureCount = 0;
|
||||
|
||||
XmlAttribute nameAttr = startNode.Attributes["fullname"];
|
||||
string suiteName = (nameAttr != null)
|
||||
? nameAttr.Value
|
||||
: "<anonymous>";
|
||||
|
||||
Trace.WriteLine("################################ UNIT TESTS ################################");
|
||||
Trace.WriteLine("Running tests in '" + suiteName + "'...");
|
||||
}
|
||||
}
|
||||
|
||||
public void TestFinished(XmlNode testResult)
|
||||
{
|
||||
XmlAttribute resultAttr = testResult.Attributes["result"];
|
||||
string resultState = resultAttr == null
|
||||
? "Unknown"
|
||||
: resultAttr.Value;
|
||||
XmlAttribute nameAttr = testResult.Attributes["fullname"];
|
||||
|
||||
switch (resultState)
|
||||
{
|
||||
case "Failed":
|
||||
_testRunCount++;
|
||||
_failureCount++;
|
||||
|
||||
_messages.Add(string.Format("{0}) {1} :", _failureCount, nameAttr.Value));
|
||||
break;
|
||||
|
||||
case "Inconclusive":
|
||||
case "Passed":
|
||||
_testRunCount++;
|
||||
break;
|
||||
|
||||
case "Skipped":
|
||||
_testIgnoreCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
var outputNode = testResult.SelectSingleNode("output");
|
||||
|
||||
if (_displayLabels == "ALL")
|
||||
WriteTestLabel(nameAttr.Value);
|
||||
if (outputNode != null)
|
||||
{
|
||||
if (_displayLabels == "ON")
|
||||
WriteTestLabel(nameAttr.Value);
|
||||
|
||||
WriteTestOutput(outputNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteTestLabel(string name)
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.SectionHeader))
|
||||
_outWriter.WriteLine("=> {0}", name);
|
||||
}
|
||||
|
||||
private void WriteTestOutput(XmlNode outputNode)
|
||||
{
|
||||
using (new ColorConsole(ColorStyle.Output))
|
||||
{
|
||||
_outWriter.Write(outputNode.InnerText);
|
||||
// Some labels were being shown on the same line as the previous output
|
||||
if (!outputNode.InnerText.EndsWith("\n"))
|
||||
{
|
||||
_outWriter.WriteLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SuiteFinished(XmlNode suiteResult)
|
||||
{
|
||||
if (--_level == 0)
|
||||
{
|
||||
XmlAttribute durationAttribute = suiteResult.Attributes["duration"];
|
||||
|
||||
Trace.WriteLine("############################################################################");
|
||||
|
||||
if (_messages.Count == 0)
|
||||
{
|
||||
Trace.WriteLine("############## S U C C E S S #################");
|
||||
}
|
||||
else
|
||||
{
|
||||
Trace.WriteLine("############## F A I L U R E S #################");
|
||||
|
||||
foreach (string s in _messages)
|
||||
{
|
||||
Trace.WriteLine(s);
|
||||
}
|
||||
}
|
||||
|
||||
Trace.WriteLine("############################################################################");
|
||||
Trace.WriteLine("Executed tests : " + _testRunCount);
|
||||
Trace.WriteLine("Ignored tests : " + _testIgnoreCount);
|
||||
Trace.WriteLine("Failed tests : " + _failureCount);
|
||||
if ( durationAttribute != null )
|
||||
Trace.WriteLine("Total duration : " + durationAttribute.Value + " seconds");
|
||||
Trace.WriteLine("############################################################################");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public override object InitializeLifetimeService()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,253 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
public enum ColorStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// Color for headers
|
||||
/// </summary>
|
||||
Header,
|
||||
/// <summary>
|
||||
/// Color for sub-headers
|
||||
/// </summary>
|
||||
SubHeader,
|
||||
/// <summary>
|
||||
/// Color for each of the section headers
|
||||
/// </summary>
|
||||
SectionHeader,
|
||||
/// <summary>
|
||||
/// The default color for items that don't fit into the other categories
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// Test output
|
||||
/// </summary>
|
||||
Output,
|
||||
/// <summary>
|
||||
/// Color for labels
|
||||
/// </summary>
|
||||
Label,
|
||||
/// <summary>
|
||||
/// Color for values, usually go beside labels
|
||||
/// </summary>
|
||||
Value,
|
||||
/// <summary>
|
||||
/// Color for passed tests
|
||||
/// </summary>
|
||||
Pass,
|
||||
/// <summary>
|
||||
/// Color for failed tests
|
||||
/// </summary>
|
||||
Failure,
|
||||
/// <summary>
|
||||
/// Color for warnings, ignored or skipped tests
|
||||
/// </summary>
|
||||
Warning,
|
||||
/// <summary>
|
||||
/// Color for errors and exceptions
|
||||
/// </summary>
|
||||
Error
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the console color in the constructor and resets it in the dispose
|
||||
/// </summary>
|
||||
public class ColorConsole : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the Enabled flag, indicating whether color is
|
||||
/// being used. This must be set at program startup.
|
||||
/// </summary>
|
||||
public static bool Enabled { get; set; }
|
||||
|
||||
public ColorConsole(ColorStyle style)
|
||||
{
|
||||
if (ColorConsole.Enabled)
|
||||
Console.ForegroundColor = GetColor(style);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the value with the specified style.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void Write(ColorStyle style, string value)
|
||||
{
|
||||
using (new ColorConsole(style))
|
||||
{
|
||||
Console.Write(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the value with the specified style.
|
||||
/// </summary>
|
||||
/// <param name="style">The style.</param>
|
||||
/// <param name="value">The value.</param>
|
||||
public static void WriteLine(ColorStyle style, string value)
|
||||
{
|
||||
using (new ColorConsole(style))
|
||||
{
|
||||
Console.WriteLine(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the label and the option that goes with it and optionally writes a new line.
|
||||
/// </summary>
|
||||
/// <param name="label">The label.</param>
|
||||
/// <param name="option">The option.</param>
|
||||
/// <param name="writeLine">if set to <c>true</c> [write line].</param>
|
||||
public static void WriteLabel(string label, string option, bool writeLine)
|
||||
{
|
||||
WriteLabel(label, option, ColorStyle.Value, writeLine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes the label and the option that goes with it and optionally writes a new line.
|
||||
/// </summary>
|
||||
/// <param name="label">The label.</param>
|
||||
/// <param name="option">The option.</param>
|
||||
/// <param name="valueStyle">The color to display the value with</param>
|
||||
/// <param name="writeLine">if set to <c>true</c> [write line].</param>
|
||||
public static void WriteLabel(string label, string option, ColorStyle valueStyle, bool writeLine)
|
||||
{
|
||||
Write(ColorStyle.Label, label);
|
||||
Write(valueStyle, option);
|
||||
if (writeLine)
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// By using styles, we can keep everything consistent
|
||||
/// </summary>
|
||||
/// <param name="style"></param>
|
||||
/// <returns></returns>
|
||||
public static ConsoleColor GetColor(ColorStyle style)
|
||||
{
|
||||
switch (Console.BackgroundColor)
|
||||
{
|
||||
case ConsoleColor.White:
|
||||
switch (style)
|
||||
{
|
||||
case ColorStyle.Header:
|
||||
return ConsoleColor.DarkBlue;
|
||||
case ColorStyle.SubHeader:
|
||||
return ConsoleColor.DarkGray;
|
||||
case ColorStyle.SectionHeader:
|
||||
return ConsoleColor.DarkBlue;
|
||||
case ColorStyle.Label:
|
||||
return ConsoleColor.DarkGreen;
|
||||
case ColorStyle.Value:
|
||||
return ConsoleColor.Blue;
|
||||
case ColorStyle.Pass:
|
||||
return ConsoleColor.Green;
|
||||
case ColorStyle.Failure:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Warning:
|
||||
return ConsoleColor.Yellow;
|
||||
case ColorStyle.Error:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Output:
|
||||
return ConsoleColor.DarkGray;
|
||||
case ColorStyle.Default:
|
||||
default:
|
||||
return ConsoleColor.Green;
|
||||
}
|
||||
|
||||
case ConsoleColor.Gray:
|
||||
switch (style)
|
||||
{
|
||||
case ColorStyle.Header:
|
||||
return ConsoleColor.White;
|
||||
case ColorStyle.SubHeader:
|
||||
return ConsoleColor.DarkGray;
|
||||
case ColorStyle.SectionHeader:
|
||||
return ConsoleColor.Cyan;
|
||||
case ColorStyle.Label:
|
||||
return ConsoleColor.Green;
|
||||
case ColorStyle.Value:
|
||||
return ConsoleColor.White;
|
||||
case ColorStyle.Pass:
|
||||
return ConsoleColor.Green;
|
||||
case ColorStyle.Failure:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Warning:
|
||||
return ConsoleColor.Yellow;
|
||||
case ColorStyle.Error:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Output:
|
||||
return ConsoleColor.DarkGray;
|
||||
case ColorStyle.Default:
|
||||
default:
|
||||
return ConsoleColor.Green;
|
||||
}
|
||||
|
||||
default:
|
||||
switch (style)
|
||||
{
|
||||
case ColorStyle.Header:
|
||||
return ConsoleColor.White;
|
||||
case ColorStyle.SubHeader:
|
||||
return ConsoleColor.Gray;
|
||||
case ColorStyle.SectionHeader:
|
||||
return ConsoleColor.Cyan;
|
||||
case ColorStyle.Label:
|
||||
return ConsoleColor.Green;
|
||||
case ColorStyle.Value:
|
||||
return ConsoleColor.White;
|
||||
case ColorStyle.Pass:
|
||||
return ConsoleColor.Green;
|
||||
case ColorStyle.Failure:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Warning:
|
||||
return ConsoleColor.Yellow;
|
||||
case ColorStyle.Error:
|
||||
return ConsoleColor.Red;
|
||||
case ColorStyle.Output:
|
||||
return ConsoleColor.Gray;
|
||||
case ColorStyle.Default:
|
||||
default:
|
||||
return ConsoleColor.Green;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Implementation of IDisposable
|
||||
|
||||
/// <summary>
|
||||
/// If color is enabled, restores the console colors to their defaults
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (ColorConsole.Enabled)
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// PackageSettings is a static class containing constant values that
|
||||
/// are used as keys in setting up a TestPackage. These values duplicate
|
||||
/// settings in the engine and framework.
|
||||
/// </summary>
|
||||
public static class PackageSettings
|
||||
{
|
||||
#region Settings taken from RunnerSettings in the engine
|
||||
|
||||
/// <summary>
|
||||
/// The config to use in loading a project
|
||||
/// </summary>
|
||||
public const string ActiveConfig = "ActiveConfig";
|
||||
|
||||
/// <summary>
|
||||
/// If true, the engine should determine the private bin
|
||||
/// path by examining the paths to all the tests.
|
||||
/// </summary>
|
||||
public const string AutoBinPath = "AutoBinPath";
|
||||
|
||||
/// <summary>
|
||||
/// The ApplicationBase to use in loading the tests.
|
||||
/// </summary>
|
||||
public const string BasePath = "BasePath";
|
||||
|
||||
/// <summary>
|
||||
/// The config file to use in running the tests
|
||||
/// </summary>
|
||||
public const string ConfigurationFile = "ConfigurationFile";
|
||||
|
||||
/// <summary>
|
||||
/// Indicates how to load tests across AppDomains
|
||||
/// </summary>
|
||||
public const string DomainUsage = "DomainUsage";
|
||||
|
||||
/// <summary>
|
||||
/// The private binpath used to locate assemblies
|
||||
/// </summary>
|
||||
public const string PrivateBinPath = "PrivateBinPath";
|
||||
|
||||
/// <summary>
|
||||
/// Indicates how to allocate assemblies to processes
|
||||
/// </summary>
|
||||
public const string ProcessModel = "ProcessModel";
|
||||
|
||||
/// <summary>
|
||||
/// Indicates the desired runtime to use for the tests.
|
||||
/// </summary>
|
||||
public const string RuntimeFramework = "RuntimeFramework";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Settings taken from DriverSettings in the framework
|
||||
|
||||
/// <summary>
|
||||
/// The default log threshold to be captured. Defaults to "Error"
|
||||
/// Use "None" to turn off capture. Other values depend on the
|
||||
/// logging subsystem. Currently, log4net is supported.
|
||||
/// </summary>
|
||||
public const string DefaultLogThreshold = "DefaultLogThreshold";
|
||||
|
||||
/// <summary>
|
||||
/// Integer value in milliseconds for the default timeout value
|
||||
/// for test cases. If not specified, there is no timeout.
|
||||
/// </summary>
|
||||
public const string DefaultTimeout = "DefaultTimeout";
|
||||
|
||||
/// <summary>
|
||||
/// An InternalTraceLevel enumeration value for this run.
|
||||
/// </summary>
|
||||
public const string InternalTraceLevel = "InternalTraceLevel";
|
||||
|
||||
/// <summary>
|
||||
/// A TextWriter to which the internal trace will be sent.
|
||||
/// </summary>
|
||||
public const string InternalTraceWriter = "InternalTraceWriter";
|
||||
|
||||
/// <summary>
|
||||
/// A list of tests to be loaded.
|
||||
/// </summary>
|
||||
// TODO: Remove?
|
||||
public const string LOAD = "LOAD";
|
||||
|
||||
/// <summary>
|
||||
/// The number of test threads to run for the assembly.
|
||||
/// </summary>
|
||||
public const string NumberOfTestWorkers = "NumberOfTestWorkers";
|
||||
|
||||
/// <summary>
|
||||
/// The random seed to be used for this assembly.
|
||||
/// </summary>
|
||||
public const string RandomSeed = "RandomSeed";
|
||||
|
||||
/// <summary>
|
||||
/// If true, execution stops after the first error or failure.
|
||||
/// </summary>
|
||||
public const string StopOnError = "StopOnError";
|
||||
|
||||
/// <summary>
|
||||
/// Full path of the directory to be used for work and result files.
|
||||
/// </summary>
|
||||
public const string WorkDirectory = "WorkDirectory";
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2007 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for StackTraceFilter.
|
||||
/// </summary>
|
||||
public static class StackTraceFilter
|
||||
{
|
||||
public static string Filter(string stack)
|
||||
{
|
||||
if (stack == null) return null;
|
||||
StringWriter sw = new StringWriter();
|
||||
StringReader sr = new StringReader(stack);
|
||||
|
||||
try
|
||||
{
|
||||
string line;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
if (!FilterLine(line))
|
||||
sw.WriteLine(line.Trim());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return stack;
|
||||
}
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
static bool FilterLine(string line)
|
||||
{
|
||||
string[] patterns = new string[]
|
||||
{
|
||||
"NUnit.Framework.Assert"
|
||||
};
|
||||
|
||||
for (int i = 0; i < patterns.Length; i++)
|
||||
{
|
||||
if (line.IndexOf(patterns[i]) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtainingn
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Engine;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
public class TestFilterBuilder
|
||||
{
|
||||
public IList<string> Tests { get; set; }
|
||||
public IList<string> Include { get; set; }
|
||||
public IList<string> Exclude { get; set; }
|
||||
|
||||
public TestFilterBuilder()
|
||||
{
|
||||
this.Tests = new List<string>();
|
||||
this.Include = new List<string>();
|
||||
this.Exclude = new List<string>();
|
||||
}
|
||||
|
||||
public TestFilter GetFilter()
|
||||
{
|
||||
var tests = new StringBuilder();
|
||||
var include = new StringBuilder();
|
||||
var exclude = new StringBuilder();
|
||||
|
||||
if (Tests.Count > 0)
|
||||
{
|
||||
tests.Append("<tests>");
|
||||
foreach (string test in Tests)
|
||||
tests.AppendFormat("<test>{0}</test>", test);
|
||||
tests.Append("</tests>");
|
||||
}
|
||||
|
||||
if (Include.Count > 0)
|
||||
{
|
||||
include.Append("<cat>");
|
||||
bool needComma = false;
|
||||
foreach (string category in Include)
|
||||
{
|
||||
if (needComma) include.Append(',');
|
||||
include.Append(category);
|
||||
needComma = true;
|
||||
}
|
||||
include.Append("</cat>");
|
||||
}
|
||||
|
||||
if (Exclude.Count > 0)
|
||||
{
|
||||
exclude.Append("<not><cat>");
|
||||
bool needComma = false;
|
||||
foreach (string category in Exclude)
|
||||
{
|
||||
if (needComma) exclude.Append(',');
|
||||
exclude.Append(category);
|
||||
needComma = true;
|
||||
}
|
||||
exclude.Append("</cat></not>");
|
||||
}
|
||||
|
||||
var testFilter = new StringBuilder("<filter>");
|
||||
if (tests.Length > 0)
|
||||
testFilter.Append(tests.ToString());
|
||||
if (include.Length > 0)
|
||||
testFilter.Append(include.ToString());
|
||||
if (exclude.Length > 0)
|
||||
testFilter.Append(exclude.ToString());
|
||||
testFilter.Append("</filter>");
|
||||
|
||||
return new TestFilter(testFilter.ToString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
// ****************************************************************
|
||||
// Copyright 2011, Charlie Poole
|
||||
// This is free software licensed under the NUnit license. You may
|
||||
// obtain a copy of the license at http://nunit.org
|
||||
// ****************************************************************
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// TestNameParser is used to parse the arguments to the
|
||||
/// -run option, separating testnames at the correct point.
|
||||
/// </summary>
|
||||
public class TestNameParser
|
||||
{
|
||||
/// <summary>
|
||||
/// Parse the -run argument and return an array of argument
|
||||
/// </summary>
|
||||
/// <param name="argument">argument</param>
|
||||
/// <returns></returns>
|
||||
public static string[] Parse(string argument)
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
|
||||
int index = 0;
|
||||
while (index < argument.Length)
|
||||
{
|
||||
string name = GetTestName(argument, ref index);
|
||||
if (name != null && name != string.Empty)
|
||||
list.Add(name);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
private static string GetTestName(string argument, ref int index)
|
||||
{
|
||||
int separator = GetSeparator(argument, index);
|
||||
string result;
|
||||
|
||||
if (separator >= 0)
|
||||
{
|
||||
result = argument.Substring(index, separator - index).Trim();
|
||||
index = separator + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = argument.Substring(index).Trim();
|
||||
index = argument.Length;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static int GetSeparator(string argument, int index)
|
||||
{
|
||||
int nest = 0;
|
||||
|
||||
while (index < argument.Length)
|
||||
{
|
||||
switch (argument[index])
|
||||
{
|
||||
case ',':
|
||||
if (nest == 0)
|
||||
return index;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
while (++index < argument.Length && argument[index] != '"')
|
||||
;
|
||||
break;
|
||||
|
||||
case '(':
|
||||
case '<':
|
||||
nest++;
|
||||
break;
|
||||
|
||||
case ')':
|
||||
case '>':
|
||||
nest--;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Xml;
|
||||
|
||||
namespace System.Runtime.CompilerServices
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public sealed class ExtensionAttribute : Attribute { }
|
||||
}
|
||||
|
||||
namespace NUnit.ConsoleRunner.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// XmlHelper provides static methods for basic XML operations
|
||||
/// </summary>
|
||||
public static class XmlHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new top level element node.
|
||||
/// </summary>
|
||||
/// <param name="name">The element name.</param>
|
||||
/// <returns></returns>
|
||||
public static XmlNode CreateTopLevelElement(string name)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml( "<" + name + "/>" );
|
||||
return doc.FirstChild;
|
||||
}
|
||||
|
||||
#region Safe Attribute Access
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the given attribute.
|
||||
/// </summary>
|
||||
/// <param name="result">The result.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <returns></returns>
|
||||
public static string GetAttribute(this XmlNode result, string name)
|
||||
{
|
||||
XmlAttribute attr = result.Attributes[name];
|
||||
|
||||
return attr == null ? null : attr.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the given attribute as an int.
|
||||
/// </summary>
|
||||
/// <param name="result">The result.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <returns></returns>
|
||||
public static int GetAttribute(this XmlNode result, string name, int defaultValue)
|
||||
{
|
||||
XmlAttribute attr = result.Attributes[name];
|
||||
|
||||
return attr == null
|
||||
? defaultValue
|
||||
: int.Parse(attr.Value, System.Globalization.CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the given attribute as a double.
|
||||
/// </summary>
|
||||
/// <param name="result">The result.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <returns></returns>
|
||||
public static double GetAttribute(this XmlNode result, string name, double defaultValue)
|
||||
{
|
||||
var attr = result.Attributes[name];
|
||||
|
||||
double attributeValue;
|
||||
if ( attr == null || !double.TryParse(attr.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out attributeValue) )
|
||||
return defaultValue;
|
||||
|
||||
return attributeValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of the given attribute as a DateTime.
|
||||
/// </summary>
|
||||
/// <param name="result">The result.</param>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="defaultValue">The default value.</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime GetAttribute(this XmlNode result, string name, DateTime defaultValue)
|
||||
{
|
||||
string dateStr = GetAttribute(result, name);
|
||||
if ( dateStr == null )
|
||||
return defaultValue;
|
||||
|
||||
DateTime date;
|
||||
if ( !DateTime.TryParse(dateStr, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AllowWhiteSpaces, out date) )
|
||||
return defaultValue;
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<!--
|
||||
The console runner only runs under .NET 2.0 or higher.
|
||||
The setting useLegacyV2RuntimeActivationPolicy only applies
|
||||
under .NET 4.0 and permits use of mixed mode assemblies,
|
||||
which would otherwise not load correctly.
|
||||
-->
|
||||
<startup useLegacyV2RuntimeActivationPolicy="true">
|
||||
<!-- Comment out the next line to force use of .NET 4.0 -->
|
||||
<supportedRuntime version="v2.0.50727" />
|
||||
<supportedRuntime version="v4.0.30319" />
|
||||
</startup>
|
||||
|
||||
<runtime>
|
||||
<!-- Ensure that test exceptions don't crash NUnit -->
|
||||
<legacyUnhandledExceptionPolicy enabled="1" />
|
||||
|
||||
<!-- Run partial trust V2 assemblies in full trust under .NET 4.0 -->
|
||||
<loadFromRemoteSources enabled="true" />
|
||||
|
||||
<!-- Look for addins in the addins directory for now -->
|
||||
<!--<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<probing privatePath="lib;addins"/>
|
||||
</assemblyBinding>-->
|
||||
|
||||
</runtime>
|
||||
|
||||
</configuration>
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnit-Console" default="build">
|
||||
|
||||
<patternset id="source-files">
|
||||
<include name="Properties/AssemblyInfo.cs"/>
|
||||
<include name="ColorConsole.cs" />
|
||||
<include name="ConsoleOptions.cs"/>
|
||||
<include name="ConsoleRunner.cs"/>
|
||||
<include name="IResultWriter.cs"/>
|
||||
<include name="Options.cs"/>
|
||||
<include name="PackageSettings.cs"/>
|
||||
<include name="Program.cs"/>
|
||||
<include name="ResultReporter.cs"/>
|
||||
<include name="ResultSummary.cs"/>
|
||||
<include name="StackTraceFilter.cs"/>
|
||||
<include name="TestEventHandler.cs"/>
|
||||
<include name="TestFilterBuilder.cs"/>
|
||||
<include name="TestNameParser.cs"/>
|
||||
<include name="XmlHelper.cs"/>
|
||||
<include name="OutputManager.cs"/>
|
||||
<include name="OutputSpecification.cs"/>
|
||||
<include name="OutputWriters/NUnit2XmlOutputWriter.cs"/>
|
||||
<include name="OutputWriters/NUnit3XmlOutputWriter.cs"/>
|
||||
<include name="OutputWriters/TestCaseOutputWriter.cs"/>
|
||||
<include name="OutputWriters/XmlTransformOutputWriter.cs"/>
|
||||
</patternset>
|
||||
|
||||
<target name="build">
|
||||
|
||||
<csc target="exe"
|
||||
output="${current.build.dir}/nunit-console.exe"
|
||||
debug="${build.debug}" define="${build.defines}">
|
||||
<sources>
|
||||
<patternset refid="source-files"/>
|
||||
<include name="../../GeneratedAssemblyInfo.cs"/>
|
||||
</sources>
|
||||
<nowarn>
|
||||
<warning number="1699"/>
|
||||
</nowarn>
|
||||
<references basedir="${current.build.dir}">
|
||||
<include name="nunit.engine.api.dll"/>
|
||||
</references>
|
||||
</csc>
|
||||
|
||||
<copy file="app.config"
|
||||
tofile="${current.build.dir}/nunit-console.exe.config"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
|
||||
<copy todir="${package.src.dir}/nunit-console">
|
||||
<fileset>
|
||||
<patternset refid="source-files"/>
|
||||
<include name="*.csproj"/>
|
||||
<include name="*.build"/>
|
||||
<include name="App.ico"/>
|
||||
<include name="app.config"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,97 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0DE218CA-AFB8-423A-9CD2-E22DEAC55C46}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.ConsoleRunner</RootNamespace>
|
||||
<AssemblyName>nunit-console</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Externalconsole>true</Externalconsole>
|
||||
<Commandlineparameters>nunit-console.tests.dll</Commandlineparameters>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>..\..\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\CommonVersionInfo.cs">
|
||||
<Link>CommonVersionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Utilities\ColorConsole.cs" />
|
||||
<Compile Include="Options\ConsoleOptions.cs" />
|
||||
<Compile Include="ConsoleRunner.cs" />
|
||||
<Compile Include="IResultWriter.cs" />
|
||||
<Compile Include="Options\Options.cs" />
|
||||
<Compile Include="OutputManager.cs" />
|
||||
<Compile Include="OutputSpecification.cs" />
|
||||
<Compile Include="OutputWriters\NUnit2XmlOutputWriter.cs" />
|
||||
<Compile Include="OutputWriters\NUnit3XmlOutputWriter.cs" />
|
||||
<Compile Include="OutputWriters\TestCaseOutputWriter.cs" />
|
||||
<Compile Include="OutputWriters\XmlTransformOutputWriter.cs" />
|
||||
<Compile Include="Utilities\PackageSettings.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="ResultSummary.cs" />
|
||||
<Compile Include="Utilities\StackTraceFilter.cs" />
|
||||
<Compile Include="TestEventHandler.cs" />
|
||||
<Compile Include="Utilities\TestFilterBuilder.cs" />
|
||||
<Compile Include="Utilities\TestNameParser.cs" />
|
||||
<Compile Include="ResultReporter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities\XmlHelper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="App.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="nunit-console.build" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\nunit.engine.api\nunit.engine.api.csproj">
|
||||
<Project>{775FAD50-3623-4922-97C4-DFB29A8BE4C7}</Project>
|
||||
<Name>nunit.engine.api</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,21 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NUnit Engine API")]
|
||||
[assembly: AssemblyDescription("Defines the interfaces used to access the NUnit Engine")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("c686a4e8-7c4b-4c9e-88e7-65cd1b90ba1e")]
|
||||
|
||||
// The API Assembly is maintained at a fixed version number
|
||||
[assembly: AssemblyVersion("3.0.0.0")]
|
|
@ -0,0 +1,71 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2009 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// The IFrameworkDriver interface is implemented by a class that
|
||||
/// is able to use an external framework to explore or run tests
|
||||
/// under the engine.
|
||||
/// </summary>
|
||||
public interface IFrameworkDriver
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the tests in an assembly.
|
||||
/// </summary>
|
||||
/// <returns>An Xml string representing the loaded test</returns>
|
||||
string Load();
|
||||
|
||||
/// <summary>
|
||||
/// Count the test cases that would be executed.
|
||||
/// </summary>
|
||||
/// <param name="filter">A TestFilter to use in counting the tests</param>
|
||||
/// <returns>The number of test cases counted</returns>
|
||||
int CountTestCases(TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the tests in an assembly.
|
||||
/// </summary>
|
||||
/// <param name="listener">An ITestEventHandler that receives progress notices</param>
|
||||
/// <param name="filter">A filter that controls which tests are executed</param>
|
||||
/// <returns>An Xml string representing the result</returns>
|
||||
string Run(ITestEventListener listener, TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Returns information about the tests in an assembly.
|
||||
/// </summary>
|
||||
/// <param name="filter">A filter indicating which tests to include</param>
|
||||
/// <returns>An Xml string representing the tests</returns>
|
||||
string Explore(TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the ongoing test run. If no test is running, the call is ignored.
|
||||
/// </summary>
|
||||
/// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param>
|
||||
void StopRun(bool force);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2012 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for logging within the engine
|
||||
/// </summary>
|
||||
public interface ILogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Logs the specified message at the error level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
void Error(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the error level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="args">The arguments.</param>
|
||||
void Error(string message, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the warning level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
void Warning(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the warning level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="args">The arguments.</param>
|
||||
void Warning(string message, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the info level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
void Info(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the info level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="args">The arguments.</param>
|
||||
void Info(string message, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the debug level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
void Debug(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Logs the specified message at the debug level.
|
||||
/// </summary>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="args">The arguments.</param>
|
||||
void Debug(string message, params object[] args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to abstract getting loggers
|
||||
/// </summary>
|
||||
public interface ILogging
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the logger.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the logger to get.</param>
|
||||
/// <returns></returns>
|
||||
ILogger GetLogger(string name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2007 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// The IRecentFiles interface is used to isolate the app
|
||||
/// from various implementations of recent files.
|
||||
/// </summary>
|
||||
public interface IRecentFiles
|
||||
{
|
||||
/// <summary>
|
||||
/// The max number of files saved
|
||||
/// </summary>
|
||||
int MaxFiles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of all the file entries
|
||||
/// </summary>
|
||||
/// <returns>The most recent file list</returns>
|
||||
IList<string> Entries { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Set the most recent file name, reordering
|
||||
/// the saved names as needed and removing the oldest
|
||||
/// if the max number of files would be exceeded.
|
||||
/// The current CLR version is used to create the entry.
|
||||
/// </summary>
|
||||
void SetMostRecent( string fileName );
|
||||
|
||||
/// <summary>
|
||||
/// Remove a file from the list
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to remove</param>
|
||||
void Remove( string fileName );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// IServiceLocator allows clients to locate any NUnit services
|
||||
/// for which the interface is referenced. In normal use, this
|
||||
/// linits it to those services using interfaces defined in the
|
||||
/// nunit.engine.api assembly.
|
||||
/// </summary>
|
||||
public interface IServiceLocator
|
||||
{
|
||||
/// <summary>
|
||||
/// Return a specified type of service
|
||||
/// </summary>
|
||||
T GetService<T>() where T : class;
|
||||
|
||||
/// <summary>
|
||||
/// Return a specified type of service
|
||||
/// </summary>
|
||||
object GetService(Type serviceType);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler for settings changes
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="args">The <see cref="SettingsEventArgs"/> instance containing the event data.</param>
|
||||
public delegate void SettingsEventHandler(object sender, SettingsEventArgs args);
|
||||
|
||||
/// <summary>
|
||||
/// Event argument for settings changes
|
||||
/// </summary>
|
||||
public class SettingsEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SettingsEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="settingName">Name of the setting that has changed.</param>
|
||||
public SettingsEventArgs(string settingName)
|
||||
{
|
||||
SettingName = settingName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the setting that has changed
|
||||
/// </summary>
|
||||
public string SettingName { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The ISettings interface is used to access all user
|
||||
/// settings and options.
|
||||
/// </summary>
|
||||
public interface ISettings
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when the settings are changed.
|
||||
/// </summary>
|
||||
event SettingsEventHandler Changed;
|
||||
|
||||
/// <summary>
|
||||
/// Load a setting from the storage.
|
||||
/// </summary>
|
||||
/// <param name="settingName">Name of the setting to load</param>
|
||||
/// <returns>Value of the setting or null</returns>
|
||||
object GetSetting(string settingName);
|
||||
|
||||
/// <summary>
|
||||
/// Load a setting from the storage or return a default value
|
||||
/// </summary>
|
||||
/// <param name="settingName">Name of the setting to load</param>
|
||||
/// <param name="defaultValue">Value to return if the setting is missing</param>
|
||||
/// <returns>Value of the setting or the default value</returns>
|
||||
T GetSetting<T>(string settingName, T defaultValue);
|
||||
|
||||
/// <summary>
|
||||
/// Remove a setting from the storage
|
||||
/// </summary>
|
||||
/// <param name="settingName">Name of the setting to remove</param>
|
||||
void RemoveSetting(string settingName);
|
||||
|
||||
/// <summary>
|
||||
/// Remove an entire group of settings from the storage
|
||||
/// </summary>
|
||||
/// <param name="groupName">Name of the group to remove</param>
|
||||
void RemoveGroup(string groupName);
|
||||
|
||||
/// <summary>
|
||||
/// Save a setting in the storage
|
||||
/// </summary>
|
||||
/// <param name="settingName">Name of the setting to save</param>
|
||||
/// <param name="settingValue">Value to be saved</param>
|
||||
void SaveSetting(string settingName, object settingValue);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// ITestEngine represents an instance of the test engine.
|
||||
/// Clients wanting to discover, explore or run tests start
|
||||
/// require an instance of the engine, which is generally
|
||||
/// acquired from the TestEngineActivator class.
|
||||
/// </summary>
|
||||
public interface ITestEngine : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the IServiceLocator interface, which gives access to
|
||||
/// certain services provided by the engine.
|
||||
/// </summary>
|
||||
IServiceLocator Services { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the directory path used by the engine for saving files.
|
||||
/// Some services may ignore changes to this path made after initialization.
|
||||
/// The default value is the current directory.
|
||||
/// </summary>
|
||||
string WorkDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets and sets the InternalTraceLevel used by the engine. Changing this
|
||||
/// setting after initialization will have no effect. The default value
|
||||
/// is the value saved in the NUnit settings.
|
||||
/// </summary>
|
||||
InternalTraceLevel InternalTraceLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Create and initialize the standard set of services used in the Engine.
|
||||
/// The
|
||||
/// This interface is not normally called by user code. Programs linking
|
||||
/// only to the nunit.engine.api assembly are given a
|
||||
/// pre-initialized instance of TestEngine. Programs
|
||||
/// that link directly to nunit.engine usually do so
|
||||
/// in order to perform custom initialization.
|
||||
/// </summary>
|
||||
void InitializeServices();
|
||||
|
||||
/// <summary>
|
||||
/// Returns a test runner instance for use by clients in discovering,
|
||||
/// exploring and exeuting tests.
|
||||
/// </summary>
|
||||
/// <param name="package">The TestPackage for which the runner is intended.</param>
|
||||
/// <returns>An ITestRunner.</returns>
|
||||
ITestRunner GetRunner(TestPackage package);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2009 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// The ITestListener interface is used to receive notices of significant
|
||||
/// events while a test is running. It's single method accepts an Xml string,
|
||||
/// which may represent any event generated by the test framework, the driver
|
||||
/// or any of the runners internal to the engine. Use of Xml means that
|
||||
/// any driver and framework may add additional events and the engine will
|
||||
/// simply pass them on through this interface.
|
||||
/// </summary>
|
||||
public interface ITestEventListener
|
||||
{
|
||||
/// <summary>
|
||||
/// Handle a progress report or other event.
|
||||
/// </summary>
|
||||
/// <param name="report">An XML progress report.</param>
|
||||
void OnTestEvent(string report);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// The ITestRun class represents an ongoing test run.
|
||||
/// </summary>
|
||||
public interface ITestRun
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the result of the test.
|
||||
/// </summary>
|
||||
/// <returns>An XmlNode representing the test run result</returns>
|
||||
XmlNode Result { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Stop the current test run, specifying whether to force cancellation.
|
||||
/// If no test is running, the method returns without error.
|
||||
/// </summary>
|
||||
/// <param name="force">If true, force the stop by cancelling all threads.</param>
|
||||
/// <remarks>
|
||||
/// Note that cancelling the threads is intrinsically unsafe and is only
|
||||
/// provided on the assumption that tests do not impact production data.
|
||||
/// </remarks>
|
||||
void Stop(bool force);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011-2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface implemented by all test runners.
|
||||
/// </summary>
|
||||
public interface ITestRunner : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a flag indicating whether a test is running
|
||||
/// </summary>
|
||||
bool IsTestRunning { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Load a TestPackage for possible execution
|
||||
/// </summary>
|
||||
/// <returns>An XmlNode representing the loaded package.</returns>
|
||||
/// <remarks>
|
||||
/// This method is normally optional, since Explore and Run call
|
||||
/// it automatially when necessary. The method is kept in order
|
||||
/// to make it easier to convert older programs that use it.
|
||||
/// </remarks>
|
||||
XmlNode Load();
|
||||
|
||||
/// <summary>
|
||||
/// Unload any loaded TestPackage. If none is loaded,
|
||||
/// the call is ignored.
|
||||
/// </summary>
|
||||
void Unload();
|
||||
|
||||
/// <summary>
|
||||
/// Reload the current TestPackage
|
||||
/// </summary>
|
||||
/// <returns>An XmlNode representing the loaded package.</returns>
|
||||
XmlNode Reload();
|
||||
|
||||
/// <summary>
|
||||
/// Count the test cases that would be run under
|
||||
/// the specified filter.
|
||||
/// </summary>
|
||||
/// <param name="filter">A TestFilter</param>
|
||||
/// <returns>The count of test cases</returns>
|
||||
int CountTestCases(TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Run the tests in the loaded TestPackage and return a test result. The tests
|
||||
/// are run synchronously and the listener interface is notified as it progresses.
|
||||
/// </summary>
|
||||
/// <param name="listener">The listener that is notified as the run progresses</param>
|
||||
/// <param name="filter">A TestFilter used to select tests</param>
|
||||
/// <returns>An XmlNode giving the result of the test execution</returns>
|
||||
XmlNode Run(ITestEventListener listener, TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Start a run of the tests in the loaded TestPackage. The tests are run
|
||||
/// asynchronously and the listener interface is notified as it progresses.
|
||||
/// </summary>
|
||||
/// <param name="listener">The listener that is notified as the run progresses</param>
|
||||
/// <param name="filter">A TestFilter used to select tests</param>
|
||||
/// <returns></returns>
|
||||
ITestRun RunAsync(ITestEventListener listener, TestFilter filter);
|
||||
|
||||
/// <summary>
|
||||
/// Cancel the ongoing test run. If no test is running, the call is ignored.
|
||||
/// </summary>
|
||||
/// <param name="force">If true, cancel any ongoing test threads, otherwise wait for them to complete.</param>
|
||||
void StopRun(bool force);
|
||||
|
||||
/// <summary>
|
||||
/// Explore a loaded TestPackage and return information about the tests found.
|
||||
/// </summary>
|
||||
/// <param name="filter">The TestFilter to be used in selecting tests to explore.</param>
|
||||
/// <returns>An XmlNode representing the tests fould.</returns>
|
||||
XmlNode Explore(TestFilter filter);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2012 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// InternalTraceLevel is an enumeration controlling the
|
||||
/// level of detailed presented in the internal log.
|
||||
/// </summary>
|
||||
public enum InternalTraceLevel
|
||||
{
|
||||
/// <summary>
|
||||
/// Use the default settings as specified by the user.
|
||||
/// </summary>
|
||||
Default,
|
||||
|
||||
/// <summary>
|
||||
/// Do not display any trace messages
|
||||
/// </summary>
|
||||
Off,
|
||||
|
||||
/// <summary>
|
||||
/// Display Error messages only
|
||||
/// </summary>
|
||||
Error,
|
||||
|
||||
/// <summary>
|
||||
/// Display Warning level and higher messages
|
||||
/// </summary>
|
||||
Warning,
|
||||
|
||||
/// <summary>
|
||||
/// Display informational and higher messages
|
||||
/// </summary>
|
||||
Info,
|
||||
|
||||
/// <summary>
|
||||
/// Display debug messages and higher - i.e. all messages
|
||||
/// </summary>
|
||||
Debug,
|
||||
|
||||
/// <summary>
|
||||
/// Display debug messages and higher - i.e. all messages
|
||||
/// </summary>
|
||||
Verbose = Debug
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// NUnitEngineException is thrown when the engine has been
|
||||
/// called with improper values or when a particular facility
|
||||
/// is not available.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class NUnitEngineException : Exception
|
||||
{
|
||||
/// <summary>
|
||||
/// Construct with a message
|
||||
/// </summary>
|
||||
public NUnitEngineException(string message) : base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Construct with a message and inner exception
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <param name="innerException"></param>
|
||||
public NUnitEngineException(string message, Exception innerException) : base(message, innerException) { }
|
||||
|
||||
/// <summary>
|
||||
/// Serialization constructor
|
||||
/// </summary>
|
||||
public NUnitEngineException(SerializationInfo info, StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
// This is a preliminary implementation, which requires a specific version of the engine and only
|
||||
// loads it if it can be found in the current AppBase and ProbingPath or in the GAC.
|
||||
//
|
||||
// TODO: Find the engine in established locations known to NUnit or stored in the registry.
|
||||
//
|
||||
// TODO: Find the best available version of the engine.
|
||||
|
||||
/// <summary>
|
||||
/// TestEngineActivator creates an instance of the test engine and returns an ITestEngine interface.
|
||||
/// </summary>
|
||||
public static class TestEngineActivator
|
||||
{
|
||||
private const string DefaultAssemblyName = "nunit.engine, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL";
|
||||
private const string DefaultTypeName = "NUnit.Engine.TestEngine";
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of the test engine using default values for the assembly and type names.
|
||||
/// </summary>
|
||||
/// <returns>An ITestEngine.</returns>
|
||||
public static ITestEngine CreateInstance()
|
||||
{
|
||||
return CreateInstance(DefaultAssemblyName, DefaultTypeName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of the test engine using provided values for the assembly and type names.
|
||||
/// This method is intended for use in experimenting with alternative implementations.
|
||||
/// </summary>
|
||||
/// <param name="assemblyName">The name of the assembly to be used.</param>
|
||||
/// <param name="typeName">The name of the Type to be used.</param>
|
||||
/// <returns>An ITestEngine.</returns>
|
||||
public static ITestEngine CreateInstance(string assemblyName, string typeName)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (ITestEngine)AppDomain.CurrentDomain.CreateInstanceAndUnwrap(assemblyName, typeName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Failed to load the test engine", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// Abstract base for all test filters. A filter is represented
|
||||
/// by an XmlNode with <filter> as it's topmost element.
|
||||
/// In the console runner, filters serve only to carry this
|
||||
/// XML representation, as all filtering is done by the engine.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TestFilter
|
||||
{
|
||||
[NonSerialized]
|
||||
private XmlNode xmlNode;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestFilter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="xmlText">The XML text that specifies the filter.</param>
|
||||
public TestFilter(string xmlText)
|
||||
{
|
||||
Text = xmlText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TestFilter"/> class.
|
||||
/// </summary>
|
||||
/// <param name="node">The XML node that specifies the filter.</param>
|
||||
public TestFilter(XmlNode node)
|
||||
{
|
||||
xmlNode = node;
|
||||
Text = xmlNode.OuterXml;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The empty filter - one that always passes.
|
||||
/// </summary>
|
||||
public static readonly TestFilter Empty = new TestFilter("<filter/>");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML representation of this filter as a string.
|
||||
/// </summary>
|
||||
public string Text { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the XML representation of this filter as an XmlNode
|
||||
/// </summary>
|
||||
public XmlNode Xml
|
||||
{
|
||||
get
|
||||
{
|
||||
if(xmlNode == null)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.LoadXml(Text);
|
||||
xmlNode = doc.FirstChild;
|
||||
}
|
||||
|
||||
return xmlNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace NUnit.Engine
|
||||
{
|
||||
/// <summary>
|
||||
/// TestPackage holds information about a set of tests to
|
||||
/// be loaded by a TestRunner. Each TestPackage represents
|
||||
/// tests for a single assembly. Multiple assemblies are
|
||||
/// represented by use of subpackages.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TestPackage
|
||||
{
|
||||
private string fullName;
|
||||
private List<string> testFiles = new List<string>();
|
||||
private Dictionary<string, object> settings = new Dictionary<string, object>();
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Construct a TestPackage, specifying a file path for
|
||||
/// the assembly or project to be used.
|
||||
/// </summary>
|
||||
/// <param name="filePath">The file path.</param>
|
||||
public TestPackage(string filePath)
|
||||
{
|
||||
fullName = Path.GetFullPath(filePath);
|
||||
if (IsAssemblyFileType(filePath))
|
||||
testFiles.Add(FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Construct an anonymous TestPackage that wraps
|
||||
/// multiple assemblies or projects as subpackages.
|
||||
/// </summary>
|
||||
/// <param name="testFiles"></param>
|
||||
public TestPackage(IList<string> testFiles)
|
||||
{
|
||||
foreach (string testFile in testFiles)
|
||||
this.testFiles.Add(Path.GetFullPath(testFile));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the package
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get { return fullName == null ? null : Path.GetFileName(fullName); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the path to the file containing tests. It may be
|
||||
/// an assembly or a recognized project type.
|
||||
/// </summary>
|
||||
public string FullName
|
||||
{
|
||||
get { return fullName; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an array of the test files contained in this package
|
||||
/// </summary>
|
||||
public string[] TestFiles
|
||||
{
|
||||
get { return testFiles.ToArray(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the settings dictionary for this package.
|
||||
/// </summary>
|
||||
public IDictionary<string,object> Settings
|
||||
{
|
||||
get { return settings; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Add a test file to the package.
|
||||
/// </summary>
|
||||
/// <param name="testFile">The test file to be added</param>
|
||||
public void Add(string testFile)
|
||||
{
|
||||
testFiles.Add(testFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the value of a setting or a default.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the setting</param>
|
||||
/// <param name="defaultSetting">The default value</param>
|
||||
/// <returns></returns>
|
||||
public T GetSetting<T>(string name, T defaultSetting)
|
||||
{
|
||||
return Settings.ContainsKey(name)
|
||||
? (T)Settings[name]
|
||||
: defaultSetting;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
|
||||
private static bool IsAssemblyFileType(string path)
|
||||
{
|
||||
string extension = Path.GetExtension(path).ToLower();
|
||||
return extension == ".dll" || extension == ".exe";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnitEngineApi" default="build" basedir=".">
|
||||
|
||||
<patternset id="source-files">
|
||||
<include name="*.cs" />
|
||||
</patternset>
|
||||
|
||||
<target name="build">
|
||||
|
||||
<csc target="library"
|
||||
output="${current.build.dir}/nunit.engine.api.dll"
|
||||
doc="${current.build.dir}/nunit.engine.api.xml"
|
||||
debug="${build.debug}"
|
||||
define="${build.defines}"
|
||||
warninglevel="${warn}">
|
||||
<sources basedir=".">
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
<patternset refid="source-files" />
|
||||
</sources>
|
||||
<references basedir="${current.build.dir}">
|
||||
</references>
|
||||
</csc>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
<copy todir="${package.src.dir}/nunit.engine.api">
|
||||
<fileset>
|
||||
<patternset refid="source-files" />
|
||||
<include name="*.build" />
|
||||
<include name="*.csproj" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{775FAD50-3623-4922-97C4-DFB29A8BE4C7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NUnit.Engine</RootNamespace>
|
||||
<AssemblyName>nunit.engine.api</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\bin\Debug\nunit.engine.api.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>..\..\bin\Release\nunit.engine.api.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>
|
||||
</AssemblyOriginatorKeyFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\CommonAssemblyInfo.cs">
|
||||
<Link>CommonAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="AssemblyInfo.cs" />
|
||||
<Compile Include="IFrameworkDriver.cs" />
|
||||
<Compile Include="ILogger.cs" />
|
||||
<Compile Include="ILogging.cs" />
|
||||
<Compile Include="InternalTraceLevel.cs" />
|
||||
<Compile Include="IServiceLocator.cs" />
|
||||
<Compile Include="ISettings.cs" />
|
||||
<Compile Include="ITestEngine.cs" />
|
||||
<Compile Include="ITestEventListener.cs" />
|
||||
<Compile Include="ITestRunner.cs" />
|
||||
<Compile Include="NUnitEngineException.cs" />
|
||||
<Compile Include="IRecentFiles.cs" />
|
||||
<Compile Include="TestEngineActivator.cs" />
|
||||
<Compile Include="TestFilter.cs" />
|
||||
<Compile Include="TestPackage.cs" />
|
||||
<Compile Include="ITestRun.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="nunit.engine.api.build" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Api.Tests
|
||||
{
|
||||
public class ServiceLocatorTests
|
||||
{
|
||||
private ITestEngine testEngine;
|
||||
|
||||
[SetUp]
|
||||
public void CreateEngine()
|
||||
{
|
||||
testEngine = new TestEngine();
|
||||
testEngine.InternalTraceLevel = InternalTraceLevel.Off;
|
||||
}
|
||||
|
||||
private void CheckAccessToService(Type serviceType)
|
||||
{
|
||||
object service = testEngine.Services.GetService(serviceType);
|
||||
Assert.NotNull(service, "GetService(Type) returned null");
|
||||
Assert.That(service, Is.InstanceOf(serviceType));
|
||||
}
|
||||
|
||||
private void CheckAccessToService<T>() where T: class
|
||||
{
|
||||
T service = testEngine.Services.GetService<T>();
|
||||
Assert.NotNull(service, "GetService<T>() returned null");
|
||||
}
|
||||
|
||||
[TestCase(typeof(ISettings))]
|
||||
[TestCase(typeof(IRecentFiles))]
|
||||
[TestCase(typeof(ITestAgency))]
|
||||
public void CanAccessUserSettings(Type serviceType)
|
||||
{
|
||||
CheckAccessToService(serviceType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtainingn
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
using NUnit.Engine;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Api.Tests
|
||||
{
|
||||
public class TestFilterTests
|
||||
{
|
||||
[Test]
|
||||
public void EmptyFilter()
|
||||
{
|
||||
TestFilter filter = TestFilter.Empty;
|
||||
Assert.That(filter.Text, Is.EqualTo("<filter/>"));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
Assert.That(filter.Xml.ChildNodes.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FilterWithOneTest()
|
||||
{
|
||||
string text = "<filter><tests><test>My.Test.Name</test></tests></filter>";
|
||||
TestFilter filter = new TestFilter(text);
|
||||
Assert.That(filter.Text, Is.EqualTo(text));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
Assert.That(filter.Xml.SelectSingleNode("tests/test").InnerText, Is.EqualTo("My.Test.Name"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FilterWithThreeTests()
|
||||
{
|
||||
string text = "<filter><tests><test>My.First.Test</test><test>My.Second.Test</test><test>My.Third.Test</test></tests></filter>";
|
||||
TestFilter filter = new TestFilter(text);
|
||||
Assert.That(filter.Text, Is.EqualTo(text));
|
||||
Assert.That(filter.Xml.Name, Is.EqualTo("filter"));
|
||||
XmlNodeList testNodes = filter.Xml.SelectNodes("tests/test");
|
||||
Assert.That(testNodes.Count, Is.EqualTo(3));
|
||||
Assert.That(testNodes[0].InnerText, Is.EqualTo("My.First.Test"));
|
||||
Assert.That(testNodes[1].InnerText, Is.EqualTo("My.Second.Test"));
|
||||
Assert.That(testNodes[2].InnerText, Is.EqualTo("My.Third.Test"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Api.Tests
|
||||
{
|
||||
public class TestPackageTests_SingleAssembly
|
||||
{
|
||||
private TestPackage package;
|
||||
|
||||
[SetUp]
|
||||
public void CreatePackage()
|
||||
{
|
||||
package = new TestPackage("test.dll");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssemblyPathIsUsedAsFilePath()
|
||||
{
|
||||
Assert.AreEqual(Path.GetFullPath("test.dll"), package.FullName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssemblyPathIsIncludedInList()
|
||||
{
|
||||
Assert.AreEqual(
|
||||
new string[] { Path.GetFullPath("test.dll") },
|
||||
package.TestFiles);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FileNameIsUsedAsPackageName()
|
||||
{
|
||||
Assert.That(package.Name, Is.EqualTo("test.dll"));
|
||||
}
|
||||
}
|
||||
|
||||
public class TestPackageTests_MultipleAssemblies
|
||||
{
|
||||
private TestPackage package;
|
||||
|
||||
[SetUp]
|
||||
public void CreatePackage()
|
||||
{
|
||||
package = new TestPackage(new string[] { "test1.dll", "test2.dll", "test3.dll" });
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PackageIsAnonymous()
|
||||
{
|
||||
Assert.Null(package.FullName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssemblyPathsAreIncludedInList()
|
||||
{
|
||||
string[] expectedAssemblies = new string[] {
|
||||
Path.GetFullPath("test1.dll"),
|
||||
Path.GetFullPath("test2.dll"),
|
||||
Path.GetFullPath("test3.dll") };
|
||||
|
||||
Assert.AreEqual(expectedAssemblies, package.TestFiles);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("tests")]
|
||||
[assembly: AssemblyDescription("Tests of the NUnit Engine")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("37f4a88d-9f41-462e-ac05-93f1d390b700")]
|
|
@ -0,0 +1,56 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AssemblyHelperTests
|
||||
{
|
||||
[Test]
|
||||
public void GetPathForAssembly()
|
||||
{
|
||||
string path = AssemblyHelper.GetAssemblyPath(this.GetType().Assembly);
|
||||
Assert.That(Path.GetFileName(path), Is.EqualTo("nunit.engine.tests.dll").IgnoreCase);
|
||||
Assert.That(File.Exists(path));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetPathForType()
|
||||
{
|
||||
string path = AssemblyHelper.GetAssemblyPath(this.GetType());
|
||||
Assert.That(Path.GetFileName(path), Is.EqualTo("nunit.engine.tests.dll").IgnoreCase);
|
||||
Assert.That(File.Exists(path));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetDirectoryName()
|
||||
{
|
||||
string path = AssemblyHelper.GetDirectoryName(this.GetType().Assembly);
|
||||
Assert.That(File.Exists(Path.Combine(path, "nunit.engine.tests.dll")));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using System.IO;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class AssemblyReaderTests
|
||||
{
|
||||
private AssemblyReader rdr;
|
||||
|
||||
[SetUp]
|
||||
public void CreateReader()
|
||||
{
|
||||
rdr = new AssemblyReader( this.GetType().Assembly );
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void DisposeReader()
|
||||
{
|
||||
if ( rdr != null )
|
||||
rdr.Dispose();
|
||||
|
||||
rdr = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateFromPath()
|
||||
{
|
||||
string path = AssemblyHelper.GetAssemblyPath(System.Reflection.Assembly.GetAssembly(GetType()));
|
||||
Assert.AreEqual(path, new AssemblyReader(path).AssemblyPath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateFromAssembly()
|
||||
{
|
||||
string path = AssemblyHelper.GetAssemblyPath(System.Reflection.Assembly.GetAssembly(GetType()));
|
||||
Assert.AreEqual(path, rdr.AssemblyPath);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsValidPeFile()
|
||||
{
|
||||
Assert.IsTrue(rdr.IsValidPeFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsValidPeFile_Fails()
|
||||
{
|
||||
string path = AssemblyHelper.GetAssemblyPath(System.Reflection.Assembly.GetAssembly(GetType()));
|
||||
path = Path.Combine(Path.GetDirectoryName(path), "nunit.engine.api.xml");
|
||||
Assert.IsFalse(new AssemblyReader(path).IsValidPeFile);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsDotNetFile()
|
||||
{
|
||||
Assert.IsTrue( rdr.IsDotNetFile );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImageRuntimeVersion()
|
||||
{
|
||||
string runtimeVersion = rdr.ImageRuntimeVersion;
|
||||
|
||||
StringAssert.StartsWith( "v", runtimeVersion );
|
||||
new Version( runtimeVersion.Substring( 1 ) );
|
||||
// This fails when we force running under a prior version
|
||||
// Assert.LessOrEqual( version, Environment.Version );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,291 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2014 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web.UI;
|
||||
using System.Xml;
|
||||
using NUnit.Engine.Tests.Assemblies;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Framework.Internal;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
// Functional tests of the NUnitFrameworkDriver calling into the framework.
|
||||
public class NUnitFrameworkDriverTests
|
||||
{
|
||||
private string MOCK_ASSEMBLY = "mock-assembly.dll";
|
||||
private const string MISSING_FILE = "junk.dll";
|
||||
private const string BAD_FILE = "mock-assembly.pdb";
|
||||
|
||||
private IDictionary<string, object> _settings = new Dictionary<string, object>();
|
||||
private NUnitFrameworkDriver _driver;
|
||||
private ICallbackEventHandler _handler;
|
||||
private string _mockAssemblyPath;
|
||||
|
||||
[SetUp]
|
||||
public void CreateDriver()
|
||||
{
|
||||
_mockAssemblyPath = PathUtils.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY);
|
||||
_driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, _mockAssemblyPath, _settings);
|
||||
_handler = new CallbackEventHandler();
|
||||
}
|
||||
|
||||
#region Construction Test
|
||||
//[Test]
|
||||
//public void ConstructContoller()
|
||||
//{
|
||||
// Assert.That(_controller..Builder, Is.TypeOf<DefaultTestAssemblyBuilder>());
|
||||
// Assert.That(_controller.Runner, Is.TypeOf<DefaultTestAssemblyRunner>());
|
||||
// Assert.That(_controller.AssemblyPath, Is.EqualTo(MOCK_ASSEMBLY));
|
||||
// Assert.That(_controller.Settings, Is.SameAs(_settings));
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region Load
|
||||
[Test]
|
||||
public void Load_GoodFile_ReturnsRunnableSuite()
|
||||
{
|
||||
var result = XmlHelper.CreateXmlNode(_driver.Load());
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString()));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Load_FileNotFound_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var result = XmlHelper.CreateXmlNode(
|
||||
new NUnitFrameworkDriver(AppDomain.CurrentDomain, MISSING_FILE, _settings).Load());
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(MISSING_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Load_BadFile_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var result = XmlHelper.CreateXmlNode(
|
||||
new NUnitFrameworkDriver(AppDomain.CurrentDomain, BAD_FILE, _settings).Load());
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(BAD_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Explore
|
||||
[Test]
|
||||
public void Explore_AfterLoad_ReturnsRunnableSuite()
|
||||
{
|
||||
_driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(_driver.Explore(TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString()));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreTestsAction_WithoutLoad_ThrowsInvalidOperationException()
|
||||
{
|
||||
var ex = Assert.Catch(() => _driver.Explore(TestFilter.Empty));
|
||||
if (ex is System.Reflection.TargetInvocationException)
|
||||
ex = ex.InnerException;
|
||||
Assert.That(ex, Is.TypeOf<InvalidOperationException>());
|
||||
Assert.That(ex.Message, Is.EqualTo("The Explore method was called but no test has been loaded"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreTestsAction_FileNotFound_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, MISSING_FILE, _settings);
|
||||
driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(driver.Explore(TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(MISSING_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Result should not have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExploreTestsAction_BadFile_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, BAD_FILE, _settings);
|
||||
driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(driver.Explore(TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(BAD_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Result should not have child tests");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CountTests
|
||||
[Test]
|
||||
public void CountTestsAction_AfterLoad_ReturnsCorrectCount()
|
||||
{
|
||||
_driver.Load();
|
||||
Assert.That(_driver.CountTestCases(TestFilter.Empty), Is.EqualTo(MockAssembly.Tests - MockAssembly.Explicit));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTestsAction_WithoutLoad_ThrowsInvalidOperationException()
|
||||
{
|
||||
var ex = Assert.Catch(() => _driver.CountTestCases(TestFilter.Empty));
|
||||
if (ex is System.Reflection.TargetInvocationException)
|
||||
ex = ex.InnerException;
|
||||
Assert.That(ex, Is.TypeOf<InvalidOperationException>());
|
||||
Assert.That(ex.Message, Is.EqualTo("The CountTestCases method was called but no test has been loaded"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTestsAction_FileNotFound_ReturnsZero()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, MISSING_FILE, _settings);
|
||||
driver.Load();
|
||||
Assert.That(driver.CountTestCases(TestFilter.Empty), Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTestsAction_BadFile_ReturnsZero()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, BAD_FILE, _settings);
|
||||
driver.Load();
|
||||
Assert.That(driver.CountTestCases(TestFilter.Empty), Is.EqualTo(0));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RunTests
|
||||
[Test]
|
||||
public void RunTestsAction_AfterLoad_ReturnsRunnableSuite()
|
||||
{
|
||||
_driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(_driver.Run(new NullListener(), TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString()));
|
||||
Assert.That(result.GetAttribute("result"), Is.EqualTo("Failed"));
|
||||
Assert.That(result.GetAttribute("passed"), Is.EqualTo(MockAssembly.Success.ToString()));
|
||||
Assert.That(result.GetAttribute("failed"), Is.EqualTo(MockAssembly.ErrorsAndFailures.ToString()));
|
||||
Assert.That(result.GetAttribute("skipped"), Is.EqualTo((MockAssembly.NotRunnable + MockAssembly.Ignored).ToString()));
|
||||
Assert.That(result.GetAttribute("inconclusive"), Is.EqualTo(MockAssembly.Inconclusive.ToString()));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException()
|
||||
{
|
||||
var ex = Assert.Catch(() => _driver.Run(new NullListener(), TestFilter.Empty));
|
||||
if (ex is System.Reflection.TargetInvocationException)
|
||||
ex = ex.InnerException;
|
||||
Assert.That(ex, Is.TypeOf<InvalidOperationException>());
|
||||
Assert.That(ex.Message, Is.EqualTo("The Run method was called but no test has been loaded"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RunTestsAction_FileNotFound_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, MISSING_FILE, _settings);
|
||||
driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(driver.Run(new NullListener(), TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(MISSING_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RunTestsAction_BadFile_ReturnsNonRunnableSuite()
|
||||
{
|
||||
var driver = new NUnitFrameworkDriver(AppDomain.CurrentDomain, BAD_FILE, _settings);
|
||||
driver.Load();
|
||||
var result = XmlHelper.CreateXmlNode(driver.Run(new NullListener(), TestFilter.Empty));
|
||||
|
||||
Assert.That(result.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly"));
|
||||
Assert.That(result.GetAttribute("runstate"), Is.EqualTo("NotRunnable"));
|
||||
Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
|
||||
Assert.That(GetSkipReason(result), Is.StringStarting("Could not load").And.Contains(BAD_FILE));
|
||||
Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Helper Methods
|
||||
private static string GetSkipReason(XmlNode result)
|
||||
{
|
||||
var propNode = result.SelectSingleNode(string.Format("properties/property[@name='{0}']", PropertyNames.SkipReason));
|
||||
return propNode == null ? null : propNode.GetAttribute("value");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Nested Callback Class
|
||||
private class CallbackEventHandler : System.Web.UI.ICallbackEventHandler
|
||||
{
|
||||
private string _result;
|
||||
|
||||
public string GetCallbackResult()
|
||||
{
|
||||
return _result;
|
||||
}
|
||||
|
||||
public void RaiseCallbackEvent(string eventArgument)
|
||||
{
|
||||
_result = eventArgument;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Nested NullListener Class
|
||||
public class NullListener : ITestEventListener
|
||||
{
|
||||
public void OnTestEvent(string testEvent)
|
||||
{
|
||||
// No action
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class NUnitProjectTests
|
||||
{
|
||||
private NUnitProject project;
|
||||
private static readonly char SEP = Path.DirectorySeparatorChar;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
project = new NUnitProject();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanLoadEmptyProject()
|
||||
{
|
||||
project.LoadXml(NUnitProjectXml.EmptyProject);
|
||||
|
||||
//Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
|
||||
//Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);
|
||||
|
||||
Assert.AreEqual(0, project.Configs.Count);
|
||||
|
||||
Assert.AreEqual(null, project.ActiveConfig);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadEmptyConfigs()
|
||||
{
|
||||
project.LoadXml(NUnitProjectXml.EmptyConfigs);
|
||||
|
||||
//Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
|
||||
//Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);
|
||||
|
||||
Assert.AreEqual(2, project.Configs.Count);
|
||||
Assert.AreEqual("Debug", project.ActiveConfig.Name);
|
||||
|
||||
IProjectConfig config1 = project.Configs["Debug"];
|
||||
Assert.AreEqual("Debug", config1.Name);
|
||||
Assert.AreEqual(1, config1.Settings.Count);
|
||||
Assert.AreEqual(true, config1.Settings["AutoBinPath"]);
|
||||
|
||||
IProjectConfig config2 = project.Configs["Release"];
|
||||
Assert.AreEqual("Release", config2.Name);
|
||||
Assert.AreEqual(1, config2.Settings.Count);
|
||||
Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadNormalProject()
|
||||
{
|
||||
project.LoadXml(NUnitProjectXml.NormalProject);
|
||||
|
||||
//Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
|
||||
//Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);
|
||||
|
||||
Assert.AreEqual(2, project.Configs.Count);
|
||||
Assert.AreEqual("Debug", project.ActiveConfig.Name);
|
||||
|
||||
IProjectConfig config1 = project.Configs["Debug"];
|
||||
Assert.AreEqual(2, config1.Assemblies.Length);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "debug" + SEP + "assembly1.dll",
|
||||
config1.Assemblies[0]);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "debug" + SEP + "assembly2.dll",
|
||||
config1.Assemblies[1]);
|
||||
|
||||
Assert.AreEqual(2, config1.Settings.Count);
|
||||
Assert.AreEqual("bin" + SEP + "debug", config1.Settings["BasePath"]);
|
||||
Assert.AreEqual(true, config1.Settings["AutoBinPath"]);
|
||||
|
||||
IProjectConfig config2 = project.Configs["Release"];
|
||||
Assert.AreEqual(2, config2.Assemblies.Length);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "release" + SEP + "assembly1.dll",
|
||||
config2.Assemblies[0]);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "release" + SEP + "assembly2.dll",
|
||||
config2.Assemblies[1]);
|
||||
|
||||
Assert.AreEqual(2, config2.Settings.Count);
|
||||
Assert.AreEqual("bin" + SEP + "release", config2.Settings["BasePath"]);
|
||||
Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadProjectWithManualBinPath()
|
||||
{
|
||||
project.LoadXml(NUnitProjectXml.ManualBinPathProject);
|
||||
|
||||
//Assert.AreEqual(Path.GetFullPath(xmlfile), project.ProjectPath);
|
||||
//Assert.AreEqual(Path.GetDirectoryName(project.ProjectPath), project.EffectiveBasePath);
|
||||
|
||||
Assert.AreEqual(1, project.Configs.Count);
|
||||
|
||||
IProjectConfig config1 = project.Configs["Debug"];
|
||||
Assert.AreEqual("Debug", config1.Name);
|
||||
Assert.AreEqual(1, config1.Settings.Count);
|
||||
Assert.AreEqual("bin_path_value", config1.Settings["PrivateBinPath"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LoadProjectWithComplexSettings()
|
||||
{
|
||||
project.LoadXml(NUnitProjectXml.ComplexSettingsProject);
|
||||
|
||||
Assert.AreEqual(2, project.Configs.Count);
|
||||
|
||||
IProjectConfig config1 = project.Configs["Debug"];
|
||||
Assert.AreEqual(5, config1.Settings.Count);
|
||||
Assert.AreEqual("bin" + SEP + "debug", config1.Settings["BasePath"]);
|
||||
Assert.AreEqual(true, config1.Settings["AutoBinPath"]);
|
||||
Assert.AreEqual("Separate", config1.Settings["ProcessModel"]);
|
||||
Assert.AreEqual("Multiple", config1.Settings["DomainUsage"]);
|
||||
Assert.AreEqual("v2.0", config1.Settings["RuntimeFramework"]);
|
||||
|
||||
Assert.AreEqual(2, config1.Assemblies.Length);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "debug" + SEP + "assembly1.dll",
|
||||
config1.Assemblies[0]);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "debug" + SEP + "assembly2.dll",
|
||||
config1.Assemblies[1]);
|
||||
|
||||
IProjectConfig config2 = project.Configs["Release"];
|
||||
Assert.AreEqual(5, config2.Settings.Count);
|
||||
Assert.AreEqual(true, config2.Settings["AutoBinPath"]);
|
||||
Assert.AreEqual("Separate", config2.Settings["ProcessModel"]);
|
||||
Assert.AreEqual("Multiple", config2.Settings["DomainUsage"]);
|
||||
Assert.AreEqual("v4.0", config2.Settings["RuntimeFramework"]);
|
||||
|
||||
Assert.AreEqual(2, config2.Assemblies.Length);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "release",
|
||||
config2.Settings["BasePath"]);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "release" + SEP + "assembly1.dll",
|
||||
config2.Assemblies[0]);
|
||||
Assert.AreEqual(
|
||||
"bin" + SEP + "release" + SEP + "assembly2.dll",
|
||||
config2.Assemblies[1]);
|
||||
}
|
||||
|
||||
//[Test]
|
||||
//public void MakeTestPackage()
|
||||
//{
|
||||
// project.LoadXml(NUnitProjectXml.ComplexSettingsProject);
|
||||
// IProjectConfig config = project.Configs["Release"];
|
||||
// TestPackage package = config.MakeTestPackage();
|
||||
|
||||
// Assert.AreEqual("bin" + SEP + "release", package.Settings["BasePath"]);
|
||||
// Assert.AreEqual(ProcessModel.Separate, package.Settings["ProcessModel"]);
|
||||
// Assert.AreEqual(DomainUsage.Multiple, package.Settings["DomainUsage"]);
|
||||
|
||||
// RuntimeFramework framework = (RuntimeFramework)package.Settings["RuntimeFramework"];
|
||||
// Assert.AreEqual(RuntimeType.Any, framework.Runtime);
|
||||
// Assert.AreEqual(new Version(4, 0), framework.ClrVersion);
|
||||
|
||||
// Assert.True(package.HasSubPackages);
|
||||
// Assert.AreEqual(2, package.SubPackages.Length);
|
||||
// Assert.AreEqual(
|
||||
// Path.GetFullPath(config.Assemblies[0]),
|
||||
// package.SubPackages[0].FilePath);
|
||||
// Assert.AreEqual(
|
||||
// Path.GetFullPath(config.Assemblies[1]),
|
||||
// package.SubPackages[1].FilePath);
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for NUnitProjectXml.
|
||||
/// </summary>
|
||||
public class NUnitProjectXml
|
||||
{
|
||||
public static readonly string EmptyProject = "<NUnitProject />";
|
||||
|
||||
public static readonly string EmptyConfigs =
|
||||
"<NUnitProject>" + System.Environment.NewLine +
|
||||
" <Settings activeconfig=\"Debug\" />" + System.Environment.NewLine +
|
||||
" <Config name=\"Debug\" binpathtype=\"Auto\" />" + System.Environment.NewLine +
|
||||
" <Config name=\"Release\" binpathtype=\"Auto\" />" + System.Environment.NewLine +
|
||||
"</NUnitProject>";
|
||||
|
||||
public static readonly string NormalProject =
|
||||
"<NUnitProject>" + System.Environment.NewLine +
|
||||
" <Settings activeconfig=\"Debug\" />" + System.Environment.NewLine +
|
||||
" <Config name=\"Debug\" appbase=\"bin" + Path.DirectorySeparatorChar + "debug\" binpathtype=\"Auto\">" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly1.dll\" />" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly2.dll\" />" + System.Environment.NewLine +
|
||||
" </Config>" + System.Environment.NewLine +
|
||||
" <Config name=\"Release\" appbase=\"bin" + Path.DirectorySeparatorChar + "release\" binpathtype=\"Auto\">" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly1.dll\" />" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly2.dll\" />" + System.Environment.NewLine +
|
||||
" </Config>" + System.Environment.NewLine +
|
||||
"</NUnitProject>";
|
||||
|
||||
public static readonly string ManualBinPathProject =
|
||||
"<NUnitProject>" + System.Environment.NewLine +
|
||||
" <Settings activeconfig=\"Debug\" />" + System.Environment.NewLine +
|
||||
" <Config name=\"Debug\" binpath=\"bin_path_value\" /> " + System.Environment.NewLine +
|
||||
"</NUnitProject>";
|
||||
|
||||
public static readonly string ComplexSettingsProject =
|
||||
"<NUnitProject>" + System.Environment.NewLine +
|
||||
" <Settings activeconfig=\"Release\" appbase=\"bin\" processModel=\"Separate\" domainUsage=\"Multiple\" />" + System.Environment.NewLine +
|
||||
" <Config name=\"Debug\" appbase=\"debug\" binpathtype=\"Auto\" runtimeFramework=\"v2.0\">" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly1.dll\" />" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly2.dll\" />" + System.Environment.NewLine +
|
||||
" </Config>" + System.Environment.NewLine +
|
||||
" <Config name=\"Release\" appbase=\"release\" binpathtype=\"Auto\" runtimeFramework=\"v4.0\">" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly1.dll\" />" + System.Environment.NewLine +
|
||||
" <assembly path=\"assembly2.dll\" />" + System.Environment.NewLine +
|
||||
" </Config>" + System.Environment.NewLine +
|
||||
"</NUnitProject>";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathUtilTests : PathUtils
|
||||
{
|
||||
[Test]
|
||||
public void CheckDefaults()
|
||||
{
|
||||
Assert.AreEqual( Path.DirectorySeparatorChar, PathUtils.DirectorySeparatorChar );
|
||||
Assert.AreEqual( Path.AltDirectorySeparatorChar, PathUtils.AltDirectorySeparatorChar );
|
||||
}
|
||||
}
|
||||
|
||||
// Local Assert extension
|
||||
internal class Assert : NUnit.Framework.Assert
|
||||
{
|
||||
public static void SamePathOrUnder( string path1, string path2 )
|
||||
{
|
||||
string msg = "\r\n\texpected: Same path or under <{0}>\r\n\t but was: <{1}>";
|
||||
Assert.IsTrue( PathUtils.SamePathOrUnder( path1, path2 ), msg, path1, path2 );
|
||||
}
|
||||
|
||||
public static void NotSamePathOrUnder( string path1, string path2 )
|
||||
{
|
||||
string msg = "\r\n\texpected: Not same path or under <{0}>\r\n\t but was: <{1}>";
|
||||
Assert.IsFalse( PathUtils.SamePathOrUnder( path1, path2 ), msg, path1, path2 );
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class PathUtilTests_Windows : PathUtils
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public static void SetUpUnixSeparators()
|
||||
{
|
||||
PathUtils.DirectorySeparatorChar = '\\';
|
||||
PathUtils.AltDirectorySeparatorChar = '/';
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public static void RestoreDefaultSeparators()
|
||||
{
|
||||
PathUtils.DirectorySeparatorChar = System.IO.Path.DirectorySeparatorChar;
|
||||
PathUtils.AltDirectorySeparatorChar = System.IO.Path.AltDirectorySeparatorChar;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Canonicalize()
|
||||
{
|
||||
Assert.AreEqual( @"C:\folder1\file.tmp",
|
||||
PathUtils.Canonicalize( @"C:\folder1\.\folder2\..\file.tmp" ) );
|
||||
Assert.AreEqual( @"folder1\file.tmp",
|
||||
PathUtils.Canonicalize( @"folder1\.\folder2\..\file.tmp" ) );
|
||||
Assert.AreEqual( @"folder1\file.tmp",
|
||||
PathUtils.Canonicalize( @"folder1\folder2\.\..\file.tmp" ) );
|
||||
Assert.AreEqual( @"file.tmp",
|
||||
PathUtils.Canonicalize( @"folder1\folder2\..\.\..\file.tmp" ) );
|
||||
Assert.AreEqual( @"file.tmp",
|
||||
PathUtils.Canonicalize( @"folder1\folder2\..\..\..\file.tmp" ) );
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Platform(Exclude="Linux")]
|
||||
public void RelativePath()
|
||||
{
|
||||
Assert.AreEqual( @"folder2\folder3", PathUtils.RelativePath(
|
||||
@"c:\folder1", @"c:\folder1\folder2\folder3" ) );
|
||||
Assert.AreEqual( @"..\folder2\folder3", PathUtils.RelativePath(
|
||||
@"c:\folder1", @"c:\folder2\folder3" ) );
|
||||
Assert.AreEqual( @"bin\debug", PathUtils.RelativePath(
|
||||
@"c:\folder1", @"bin\debug" ) );
|
||||
Assert.IsNull( PathUtils.RelativePath( @"C:\folder", @"D:\folder" ),
|
||||
"Unrelated paths should return null" );
|
||||
Assert.IsNull(PathUtils.RelativePath(@"C:\", @"D:\"),
|
||||
"Unrelated roots should return null");
|
||||
Assert.IsNull(PathUtils.RelativePath(@"C:", @"D:"),
|
||||
"Unrelated roots (no trailing separators) should return null");
|
||||
Assert.AreEqual(string.Empty,
|
||||
PathUtils.RelativePath(@"C:\folder1", @"C:\folder1"));
|
||||
Assert.AreEqual(string.Empty,
|
||||
PathUtils.RelativePath(@"C:\", @"C:\"));
|
||||
|
||||
// First filePath consisting just of a root:
|
||||
Assert.AreEqual(@"folder1\folder2", PathUtils.RelativePath(
|
||||
@"C:\", @"C:\folder1\folder2"));
|
||||
|
||||
// Trailing directory separator in first filePath shall be ignored:
|
||||
Assert.AreEqual(@"folder2\folder3", PathUtils.RelativePath(
|
||||
@"c:\folder1\", @"c:\folder1\folder2\folder3"));
|
||||
|
||||
// Case-insensitive behaviour, preserving 2nd filePath directories in result:
|
||||
Assert.AreEqual(@"Folder2\Folder3", PathUtils.RelativePath(
|
||||
@"C:\folder1", @"c:\folder1\Folder2\Folder3"));
|
||||
Assert.AreEqual(@"..\Folder2\folder3", PathUtils.RelativePath(
|
||||
@"c:\folder1", @"C:\Folder2\folder3"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SamePathOrUnder()
|
||||
{
|
||||
Assert.SamePathOrUnder( @"C:\folder1\folder2\folder3", @"c:\folder1\.\folder2\junk\..\folder3" );
|
||||
Assert.SamePathOrUnder( @"C:\folder1\folder2\", @"c:\folder1\.\folder2\junk\..\folder3" );
|
||||
Assert.SamePathOrUnder( @"C:\folder1\folder2", @"c:\folder1\.\folder2\junk\..\folder3" );
|
||||
Assert.SamePathOrUnder( @"C:\folder1\folder2", @"c:\folder1\.\Folder2\junk\..\folder3" );
|
||||
Assert.NotSamePathOrUnder( @"C:\folder1\folder2", @"c:\folder1\.\folder22\junk\..\folder3" );
|
||||
Assert.NotSamePathOrUnder( @"C:\folder1\folder2ile.tmp", @"D:\folder1\.\folder2\folder3\file.tmp" );
|
||||
Assert.NotSamePathOrUnder( @"C:\", @"D:\" );
|
||||
Assert.SamePathOrUnder( @"C:\", @"c:\" );
|
||||
Assert.SamePathOrUnder( @"C:\", @"c:\bin\debug" );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class PathUtilTests_Unix : PathUtils
|
||||
{
|
||||
[OneTimeSetUp]
|
||||
public static void SetUpUnixSeparators()
|
||||
{
|
||||
PathUtils.DirectorySeparatorChar = '/';
|
||||
PathUtils.AltDirectorySeparatorChar = '\\';
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public static void RestoreDefaultSeparators()
|
||||
{
|
||||
PathUtils.DirectorySeparatorChar = System.IO.Path.DirectorySeparatorChar;
|
||||
PathUtils.AltDirectorySeparatorChar = System.IO.Path.AltDirectorySeparatorChar;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Canonicalize()
|
||||
{
|
||||
Assert.AreEqual( "/folder1/file.tmp",
|
||||
PathUtils.Canonicalize( "/folder1/./folder2/../file.tmp" ) );
|
||||
Assert.AreEqual( "folder1/file.tmp",
|
||||
PathUtils.Canonicalize( "folder1/./folder2/../file.tmp" ) );
|
||||
Assert.AreEqual( "folder1/file.tmp",
|
||||
PathUtils.Canonicalize( "folder1/folder2/./../file.tmp" ) );
|
||||
Assert.AreEqual( "file.tmp",
|
||||
PathUtils.Canonicalize( "folder1/folder2/.././../file.tmp" ) );
|
||||
Assert.AreEqual( "file.tmp",
|
||||
PathUtils.Canonicalize( "folder1/folder2/../../../file.tmp" ) );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RelativePath()
|
||||
{
|
||||
Assert.AreEqual( "folder2/folder3",
|
||||
PathUtils.RelativePath( "/folder1", "/folder1/folder2/folder3" ) );
|
||||
Assert.AreEqual( "../folder2/folder3",
|
||||
PathUtils.RelativePath( "/folder1", "/folder2/folder3" ) );
|
||||
Assert.AreEqual( "bin/debug",
|
||||
PathUtils.RelativePath( "/folder1", "bin/debug" ) );
|
||||
Assert.AreEqual( "../other/folder",
|
||||
PathUtils.RelativePath( "/folder", "/other/folder" ) );
|
||||
Assert.AreEqual( "../../d",
|
||||
PathUtils.RelativePath( "/a/b/c", "/a/d" ) );
|
||||
Assert.AreEqual(string.Empty,
|
||||
PathUtils.RelativePath("/a/b", "/a/b"));
|
||||
Assert.AreEqual(string.Empty,
|
||||
PathUtils.RelativePath("/", "/"));
|
||||
|
||||
// First filePath consisting just of a root:
|
||||
Assert.AreEqual("folder1/folder2", PathUtils.RelativePath(
|
||||
"/", "/folder1/folder2"));
|
||||
|
||||
// Trailing directory separator in first filePath shall be ignored:
|
||||
Assert.AreEqual("folder2/folder3", PathUtils.RelativePath(
|
||||
"/folder1/", "/folder1/folder2/folder3"));
|
||||
|
||||
// Case-sensitive behaviour:
|
||||
Assert.AreEqual("../Folder1/Folder2/folder3",
|
||||
PathUtils.RelativePath("/folder1", "/Folder1/Folder2/folder3"),
|
||||
"folders differing in case");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SamePathOrUnder()
|
||||
{
|
||||
Assert.SamePathOrUnder( "/folder1/folder2/folder3", "/folder1/./folder2/junk/../folder3" );
|
||||
Assert.SamePathOrUnder( "/folder1/folder2/", "/folder1/./folder2/junk/../folder3" );
|
||||
Assert.SamePathOrUnder( "/folder1/folder2", "/folder1/./folder2/junk/../folder3" );
|
||||
Assert.NotSamePathOrUnder( "/folder1/folder2", "/folder1/./Folder2/junk/../folder3" );
|
||||
Assert.NotSamePathOrUnder( "/folder1/folder2", "/folder1/./folder22/junk/../folder3" );
|
||||
Assert.SamePathOrUnder( "/", "/" );
|
||||
Assert.SamePathOrUnder( "/", "/bin/debug" );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
using System.Runtime.Remoting.Channels.Tcp;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for RemotingUtilitiesTests.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class ServerUtilityTests
|
||||
{
|
||||
TcpChannel channel1;
|
||||
TcpChannel channel2;
|
||||
|
||||
[TearDown]
|
||||
public void ReleaseChannels()
|
||||
{
|
||||
ServerUtilities.SafeReleaseChannel( channel1 );
|
||||
ServerUtilities.SafeReleaseChannel( channel2 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanGetTcpChannelOnSpecifiedPort()
|
||||
{
|
||||
channel1 = ServerUtilities.GetTcpChannel( "test", 1234 );
|
||||
Assert.AreEqual( "test", channel1.ChannelName );
|
||||
channel2 = ServerUtilities.GetTcpChannel( "test", 4321 );
|
||||
Assert.AreEqual( "test", channel2.ChannelName );
|
||||
Assert.AreEqual( channel1, channel2 );
|
||||
Assert.AreSame( channel1, channel2 );
|
||||
ChannelDataStore cds = (ChannelDataStore)channel1.ChannelData;
|
||||
Assert.AreEqual( "tcp://127.0.0.1:1234", cds.ChannelUris[0] );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanGetTcpChannelOnUnpecifiedPort()
|
||||
{
|
||||
channel1 = ServerUtilities.GetTcpChannel( "test", 0 );
|
||||
Assert.AreEqual( "test", channel1.ChannelName );
|
||||
channel2 = ServerUtilities.GetTcpChannel( "test", 0 );
|
||||
Assert.AreEqual( "test", channel2.ChannelName );
|
||||
Assert.AreEqual( channel1, channel2 );
|
||||
Assert.AreSame( channel1, channel2 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SettingsGroupTests
|
||||
{
|
||||
private SettingsGroup settings;
|
||||
|
||||
[SetUp]
|
||||
public void BeforeEachTest()
|
||||
{
|
||||
settings = new SettingsGroup();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void AfterEachTest()
|
||||
{
|
||||
settings.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenSettingIsNotInitialized_NullIsReturned()
|
||||
{
|
||||
Assert.IsNull(settings.GetSetting("X"));
|
||||
Assert.IsNull(settings.GetSetting("NAME"));
|
||||
}
|
||||
|
||||
[TestCase("X", 5)]
|
||||
[TestCase("Y", 2.5)]
|
||||
[TestCase("NAME", "Charlie")]
|
||||
[TestCase("Flag", true)]
|
||||
[TestCase("Priority", PriorityValue.A)]
|
||||
public void WhenSettingIsInitialized_ValueIsReturned(string name, object expected)
|
||||
{
|
||||
settings.SaveSetting(name, expected);
|
||||
object actual = settings.GetSetting(name);
|
||||
Assert.AreEqual(expected, actual);
|
||||
Assert.IsInstanceOf(expected.GetType(),actual);
|
||||
}
|
||||
|
||||
private enum PriorityValue
|
||||
{
|
||||
A,
|
||||
B,
|
||||
C
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void WhenSettingIsRemoved_NullIsReturnedAndOtherSettingsAreNotAffected()
|
||||
{
|
||||
settings.SaveSetting("X", 5);
|
||||
settings.SaveSetting("NAME", "Charlie");
|
||||
|
||||
settings.RemoveSetting("X");
|
||||
Assert.IsNull(settings.GetSetting("X"), "X not removed");
|
||||
Assert.AreEqual("Charlie", settings.GetSetting("NAME"));
|
||||
|
||||
settings.RemoveSetting("NAME");
|
||||
Assert.IsNull(settings.GetSetting("NAME"), "NAME not removed");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenSettingIsNotInitialized_DefaultValueIsReturned()
|
||||
{
|
||||
|
||||
Assert.AreEqual( 5, settings.GetSetting( "X", 5 ) );
|
||||
Assert.AreEqual( 6, settings.GetSetting( "X", 6 ) );
|
||||
Assert.AreEqual( "7", settings.GetSetting( "X", "7" ) );
|
||||
|
||||
Assert.AreEqual( "Charlie", settings.GetSetting( "NAME", "Charlie" ) );
|
||||
Assert.AreEqual( "Fred", settings.GetSetting( "NAME", "Fred" ) );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WhenSettingIsNotValid_DefaultSettingIsReturned()
|
||||
{
|
||||
settings.SaveSetting( "X", "1y25" );
|
||||
Assert.AreEqual( 42, settings.GetSetting( "X", 42 ) );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
public class XmlHelperTests
|
||||
{
|
||||
[Test]
|
||||
public void SingleElement()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("myelement");
|
||||
|
||||
Assert.That(node.Name, Is.EqualTo("myelement"));
|
||||
Assert.That(node.Attributes.Count, Is.EqualTo(0));
|
||||
Assert.That(node.ChildNodes.Count, Is.EqualTo(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SingleElementWithAttributes()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("person");
|
||||
XmlHelper.AddAttribute(node, "name", "Fred");
|
||||
XmlHelper.AddAttribute(node, "age", "42");
|
||||
XmlHelper.AddAttribute(node, "quotes", "'c' is a char but \"c\" is a string");
|
||||
|
||||
Assert.That(node.Name, Is.EqualTo("person"));
|
||||
Assert.That(node.Attributes.Count, Is.EqualTo(3));
|
||||
Assert.That(node.ChildNodes.Count, Is.EqualTo(0));
|
||||
Assert.That(node.Attributes["name"].Value, Is.EqualTo("Fred"));
|
||||
Assert.That(node.Attributes["age"].Value, Is.EqualTo("42"));
|
||||
Assert.That(node.Attributes["quotes"].Value, Is.EqualTo("'c' is a char but \"c\" is a string"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ElementContainsElementWithInnerText()
|
||||
{
|
||||
XmlNode top = XmlHelper.CreateTopLevelElement("top");
|
||||
XmlNode message = top.AddElement("message");
|
||||
message.InnerText = "This is my message";
|
||||
|
||||
Assert.That(top.SelectSingleNode("message").InnerText, Is.EqualTo("This is my message"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ElementContainsElementWithCData()
|
||||
{
|
||||
XmlNode top = XmlHelper.CreateTopLevelElement("top");
|
||||
top.AddElementWithCDataSection("message", "x > 5 && x < 7");
|
||||
|
||||
Assert.That(top.SelectSingleNode("message").InnerText, Is.EqualTo("x > 5 && x < 7"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeAttributeAccess()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("top");
|
||||
|
||||
Assert.That(XmlHelper.GetAttribute(node, "junk"), Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeAttributeAcessWithIntDefaultValue()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("top");
|
||||
Assert.That(XmlHelper.GetAttribute(node, "junk", 42), Is.EqualTo(42));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SafeAttributeAcessWithDoubleDefaultValue()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("top");
|
||||
Assert.That(node.GetAttribute("junk", 1.234), Is.EqualTo(1.234));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine.Internal.Tests
|
||||
{
|
||||
using Framework;
|
||||
|
||||
public class ResultHelperTests
|
||||
{
|
||||
private const string resultText1 = "<test-assembly result=\"Passed\" total=\"23\" passed=\"23\" failed=\"0\" inconclusive=\"0\" skipped=\"0\" asserts=\"40\" />";
|
||||
private const string resultText2 = "<test-assembly result=\"Failed\" total=\"42\" passed=\"31\" failed=\"4\" inconclusive=\"5\" skipped=\"2\" asserts=\"53\" />";
|
||||
|
||||
private TestEngineResult result1;
|
||||
private TestEngineResult result2;
|
||||
|
||||
private TestEngineResult[] twoResults;
|
||||
|
||||
private XmlNode[] twoNodes;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
result1 = new TestEngineResult(resultText1);
|
||||
result2 = new TestEngineResult(resultText2);
|
||||
twoResults = new TestEngineResult[] { result1, result2 };
|
||||
twoNodes = new XmlNode[] { result1.Xml, result2.Xml };
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MergeTestResults()
|
||||
{
|
||||
TestEngineResult mergedResult = ResultHelper.Merge(twoResults);
|
||||
|
||||
Assert.That(mergedResult.XmlNodes.Count, Is.EqualTo(2));
|
||||
Assert.That(mergedResult.XmlNodes[0].OuterXml, Is.EqualTo(resultText1));
|
||||
Assert.That(mergedResult.XmlNodes[1].OuterXml, Is.EqualTo(resultText2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AggregateTestResult()
|
||||
{
|
||||
TestEngineResult combined = result2.Aggregate("test-run", "NAME", "FULLNAME");
|
||||
Assert.That(combined.IsSingle);
|
||||
|
||||
XmlNode combinedNode = combined.Xml;
|
||||
|
||||
Assert.That(combinedNode.Name, Is.EqualTo("test-run"));
|
||||
Assert.That(combinedNode.Attributes["result"].Value, Is.EqualTo("Failed"));
|
||||
Assert.That(combinedNode.Attributes["total"].Value, Is.EqualTo("42"));
|
||||
Assert.That(combinedNode.Attributes["passed"].Value, Is.EqualTo("31"));
|
||||
Assert.That(combinedNode.Attributes["failed"].Value, Is.EqualTo("4"));
|
||||
Assert.That(combinedNode.Attributes["inconclusive"].Value, Is.EqualTo("5"));
|
||||
Assert.That(combinedNode.Attributes["skipped"].Value, Is.EqualTo("2"));
|
||||
Assert.That(combinedNode.Attributes["asserts"].Value, Is.EqualTo("53"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MergeAndAggregateTestResults()
|
||||
{
|
||||
TestEngineResult combined = ResultHelper.Merge(twoResults).Aggregate("test-suite", "Project", "NAME", "FULLNAME");
|
||||
Assert.That(combined.IsSingle);
|
||||
|
||||
XmlNode combinedNode = combined.Xml;
|
||||
|
||||
Assert.That(combinedNode.Name, Is.EqualTo("test-suite"));
|
||||
Assert.That(combinedNode.Attributes["type"].Value, Is.EqualTo("Project"));
|
||||
Assert.That(combinedNode.Attributes["name"].Value, Is.EqualTo("NAME"));
|
||||
Assert.That(combinedNode.Attributes["fullname"].Value, Is.EqualTo("FULLNAME"));
|
||||
Assert.That(combinedNode.Attributes["result"].Value, Is.EqualTo("Failed"));
|
||||
Assert.That(combinedNode.Attributes["total"].Value, Is.EqualTo("65"));
|
||||
Assert.That(combinedNode.Attributes["passed"].Value, Is.EqualTo("54"));
|
||||
Assert.That(combinedNode.Attributes["failed"].Value, Is.EqualTo("4"));
|
||||
Assert.That(combinedNode.Attributes["inconclusive"].Value, Is.EqualTo("5"));
|
||||
Assert.That(combinedNode.Attributes["skipped"].Value, Is.EqualTo("2"));
|
||||
Assert.That(combinedNode.Attributes["asserts"].Value, Is.EqualTo("93"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AggregateXmlNodes()
|
||||
{
|
||||
DateTime startTime = new DateTime(2011, 07, 04, 12, 34, 56);
|
||||
|
||||
XmlNode combined = ResultHelper.Aggregate("test-run", "NAME", "FULLNAME", twoNodes);
|
||||
|
||||
Assert.That(combined.Name, Is.EqualTo("test-run"));
|
||||
Assert.That(combined.Attributes["name"].Value, Is.EqualTo("NAME"));
|
||||
Assert.That(combined.Attributes["fullname"].Value, Is.EqualTo("FULLNAME"));
|
||||
Assert.That(combined.Attributes["result"].Value, Is.EqualTo("Failed"));
|
||||
Assert.That(combined.Attributes["total"].Value, Is.EqualTo("65"));
|
||||
Assert.That(combined.Attributes["passed"].Value, Is.EqualTo("54"));
|
||||
Assert.That(combined.Attributes["failed"].Value, Is.EqualTo("4"));
|
||||
Assert.That(combined.Attributes["inconclusive"].Value, Is.EqualTo("5"));
|
||||
Assert.That(combined.Attributes["skipped"].Value, Is.EqualTo("2"));
|
||||
Assert.That(combined.Attributes["asserts"].Value, Is.EqualTo("93"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void InsertEnvironmentElement()
|
||||
{
|
||||
result1.Xml.InsertEnvironmentElement();
|
||||
|
||||
var env = result1.Xml.SelectSingleNode("environment");
|
||||
Assert.NotNull(env);
|
||||
|
||||
Assert.NotNull(env.GetAttribute("nunit-version"));
|
||||
Assert.NotNull(env.GetAttribute("clr-version"));
|
||||
Assert.NotNull(env.GetAttribute("os-version"));
|
||||
Assert.NotNull(env.GetAttribute("platform"));
|
||||
Assert.NotNull(env.GetAttribute("cwd"));
|
||||
Assert.NotNull(env.GetAttribute("machine-name"));
|
||||
Assert.NotNull(env.GetAttribute("user"));
|
||||
Assert.NotNull(env.GetAttribute("user-domain"));
|
||||
Assert.NotNull(env.GetAttribute("culture"));
|
||||
Assert.NotNull(env.GetAttribute("uiculture"));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace NUnit.Engine.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class RuntimeFrameworkTests
|
||||
{
|
||||
static RuntimeType currentRuntime =
|
||||
Type.GetType("Mono.Runtime", false) != null
|
||||
? RuntimeType.Mono
|
||||
: Environment.OSVersion.Platform == PlatformID.WinCE
|
||||
? RuntimeType.NetCF
|
||||
: RuntimeType.Net;
|
||||
|
||||
[Test]
|
||||
public void CanGetCurrentFramework()
|
||||
{
|
||||
RuntimeFramework framework = RuntimeFramework.CurrentFramework;
|
||||
|
||||
Assert.That(framework.Runtime, Is.EqualTo(currentRuntime));
|
||||
Assert.That(framework.ClrVersion, Is.EqualTo(Environment.Version));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CurrentFrameworkHasBuildSpecified()
|
||||
{
|
||||
Assert.That(RuntimeFramework.CurrentFramework.ClrVersion.Build, Is.GreaterThan(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CurrentFrameworkMustBeAvailable()
|
||||
{
|
||||
Assert.That(RuntimeFramework.CurrentFramework.IsAvailable);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanListAvailableFrameworks()
|
||||
{
|
||||
RuntimeFramework[] available = RuntimeFramework.AvailableFrameworks;
|
||||
Assert.That(available, Has.Length.GreaterThan(0) );
|
||||
bool foundCurrent = false;
|
||||
foreach (RuntimeFramework framework in available)
|
||||
{
|
||||
Console.WriteLine("Available: {0}", framework.DisplayName);
|
||||
foundCurrent |= RuntimeFramework.CurrentFramework.Supports(framework);
|
||||
}
|
||||
Assert.That(foundCurrent, "CurrentFramework not listed");
|
||||
}
|
||||
|
||||
[TestCaseSource("frameworkData")]
|
||||
public void CanCreateUsingFrameworkVersion(FrameworkData data)
|
||||
{
|
||||
RuntimeFramework framework = new RuntimeFramework(data.runtime, data.frameworkVersion);
|
||||
Assert.AreEqual(data.runtime, framework.Runtime);
|
||||
Assert.AreEqual(data.frameworkVersion, framework.FrameworkVersion);
|
||||
Assert.AreEqual(data.clrVersion, framework.ClrVersion);
|
||||
}
|
||||
|
||||
[TestCaseSource("frameworkData")]
|
||||
public void CanCreateUsingClrVersion(FrameworkData data)
|
||||
{
|
||||
Assume.That(data.frameworkVersion.Major != 3);
|
||||
|
||||
RuntimeFramework framework = new RuntimeFramework(data.runtime, data.clrVersion);
|
||||
Assert.AreEqual(data.runtime, framework.Runtime);
|
||||
Assert.AreEqual(data.frameworkVersion, framework.FrameworkVersion);
|
||||
Assert.AreEqual(data.clrVersion, framework.ClrVersion);
|
||||
}
|
||||
|
||||
[TestCaseSource("frameworkData")]
|
||||
public void CanParseRuntimeFramework(FrameworkData data)
|
||||
{
|
||||
RuntimeFramework framework = RuntimeFramework.Parse(data.representation);
|
||||
Assert.AreEqual(data.runtime, framework.Runtime);
|
||||
Assert.AreEqual(data.clrVersion, framework.ClrVersion);
|
||||
}
|
||||
|
||||
[TestCaseSource("frameworkData")]
|
||||
public void CanDisplayFrameworkAsString(FrameworkData data)
|
||||
{
|
||||
RuntimeFramework framework = new RuntimeFramework(data.runtime, data.frameworkVersion);
|
||||
Assert.AreEqual(data.representation, framework.ToString());
|
||||
Assert.AreEqual(data.displayName, framework.DisplayName);
|
||||
}
|
||||
|
||||
[TestCaseSource("matchData")]
|
||||
public bool CanMatchRuntimes(RuntimeFramework f1, RuntimeFramework f2)
|
||||
{
|
||||
return f1.Supports(f2);
|
||||
}
|
||||
|
||||
internal static TestCaseData[] matchData = new TestCaseData[] {
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(3,5)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(3,5)))
|
||||
.Returns(false),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(3,5)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(3,5)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Mono, new Version(2,0)))
|
||||
.Returns(false),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(1,1)))
|
||||
.Returns(false),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0,40607)))
|
||||
.Returns(false),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Mono, new Version(1,1)), // non-existent version but it works
|
||||
new RuntimeFramework(RuntimeType.Mono, new Version(1,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Mono, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Mono, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Any, new Version(4,0)))
|
||||
.Returns(false),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion),
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)))
|
||||
.Returns(true),
|
||||
new TestCaseData(
|
||||
new RuntimeFramework(RuntimeType.Net, new Version(2,0)),
|
||||
new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion))
|
||||
.Returns(true)
|
||||
};
|
||||
|
||||
public struct FrameworkData
|
||||
{
|
||||
public RuntimeType runtime;
|
||||
public Version frameworkVersion;
|
||||
public Version clrVersion;
|
||||
public string representation;
|
||||
public string displayName;
|
||||
|
||||
public FrameworkData(RuntimeType runtime, Version frameworkVersion, Version clrVersion,
|
||||
string representation, string displayName)
|
||||
{
|
||||
this.runtime = runtime;
|
||||
this.frameworkVersion = frameworkVersion;
|
||||
this.clrVersion = clrVersion;
|
||||
this.representation = representation;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("<{0}-{1}>", this.runtime, this.frameworkVersion);
|
||||
}
|
||||
}
|
||||
|
||||
internal FrameworkData[] frameworkData = new FrameworkData[] {
|
||||
new FrameworkData(RuntimeType.Net, new Version(1,0), new Version(1,0,3705), "net-1.0", "Net 1.0"),
|
||||
//new FrameworkData(RuntimeType.Net, new Version(1,0,3705), new Version(1,0,3705), "net-1.0.3705", "Net 1.0.3705"),
|
||||
//new FrameworkData(RuntimeType.Net, new Version(1,0), new Version(1,0,3705), "net-1.0.3705", "Net 1.0.3705"),
|
||||
new FrameworkData(RuntimeType.Net, new Version(1,1), new Version(1,1,4322), "net-1.1", "Net 1.1"),
|
||||
//new FrameworkData(RuntimeType.Net, new Version(1,1,4322), new Version(1,1,4322), "net-1.1.4322", "Net 1.1.4322"),
|
||||
new FrameworkData(RuntimeType.Net, new Version(2,0), new Version(2,0,50727), "net-2.0", "Net 2.0"),
|
||||
//new FrameworkData(RuntimeType.Net, new Version(2,0,40607), new Version(2,0,40607), "net-2.0.40607", "Net 2.0.40607"),
|
||||
//new FrameworkData(RuntimeType.Net, new Version(2,0,50727), new Version(2,0,50727), "net-2.0.50727", "Net 2.0.50727"),
|
||||
new FrameworkData(RuntimeType.Net, new Version(3,0), new Version(2,0,50727), "net-3.0", "Net 3.0"),
|
||||
new FrameworkData(RuntimeType.Net, new Version(3,5), new Version(2,0,50727), "net-3.5", "Net 3.5"),
|
||||
new FrameworkData(RuntimeType.Net, new Version(4,0), new Version(4,0,30319), "net-4.0", "Net 4.0"),
|
||||
new FrameworkData(RuntimeType.Net, RuntimeFramework.DefaultVersion, RuntimeFramework.DefaultVersion, "net", "Net"),
|
||||
new FrameworkData(RuntimeType.Mono, new Version(1,0), new Version(1,1,4322), "mono-1.0", "Mono 1.0"),
|
||||
new FrameworkData(RuntimeType.Mono, new Version(2,0), new Version(2,0,50727), "mono-2.0", "Mono 2.0"),
|
||||
//new FrameworkData(RuntimeType.Mono, new Version(2,0,50727), new Version(2,0,50727), "mono-2.0.50727", "Mono 2.0.50727"),
|
||||
new FrameworkData(RuntimeType.Mono, new Version(3,5), new Version(2,0,50727), "mono-3.5", "Mono 3.5"),
|
||||
new FrameworkData(RuntimeType.Mono, new Version(4,0), new Version(4,0,30319), "mono-4.0", "Mono 4.0"),
|
||||
new FrameworkData(RuntimeType.Mono, RuntimeFramework.DefaultVersion, RuntimeFramework.DefaultVersion, "mono", "Mono"),
|
||||
new FrameworkData(RuntimeType.Any, new Version(1,1), new Version(1,1,4322), "v1.1", "v1.1"),
|
||||
new FrameworkData(RuntimeType.Any, new Version(2,0), new Version(2,0,50727), "v2.0", "v2.0"),
|
||||
//new FrameworkData(RuntimeType.Any, new Version(2,0,50727), new Version(2,0,50727), "v2.0.50727", "v2.0.50727"),
|
||||
new FrameworkData(RuntimeType.Any, new Version(3,5), new Version(2,0,50727), "v3.5", "v3.5"),
|
||||
new FrameworkData(RuntimeType.Any, new Version(4,0), new Version(4,0,30319), "v4.0", "v4.0"),
|
||||
new FrameworkData(RuntimeType.Any, RuntimeFramework.DefaultVersion, RuntimeFramework.DefaultVersion, "any", "Any")
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2011 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using NUnit.Engine.Tests.Assemblies;
|
||||
|
||||
namespace NUnit.Engine.Services.Tests
|
||||
{
|
||||
public class DomainManagerTests
|
||||
{
|
||||
static string path1 = TestPath("/test/bin/debug/test1.dll");
|
||||
static string path2 = TestPath("/test/bin/debug/test2.dll");
|
||||
static string path3 = TestPath("/test/utils/test3.dll");
|
||||
|
||||
[Test]
|
||||
public void GetPrivateBinPath()
|
||||
{
|
||||
string[] assemblies = new string[] { path1, path2, path3 };
|
||||
|
||||
Assert.AreEqual(
|
||||
TestPath("bin/debug") + Path.PathSeparator + TestPath("utils"),
|
||||
DomainManager.GetPrivateBinPath(TestPath("/test"), assemblies));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCommonAppBase_OneElement()
|
||||
{
|
||||
string[] assemblies = new string[] { path1 };
|
||||
|
||||
Assert.AreEqual(
|
||||
TestPath("/test/bin/debug"),
|
||||
DomainManager.GetCommonAppBase(assemblies));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCommonAppBase_TwoElements_SameDirectory()
|
||||
{
|
||||
string[] assemblies = new string[] { path1, path2 };
|
||||
|
||||
Assert.AreEqual(
|
||||
TestPath("/test/bin/debug"),
|
||||
DomainManager.GetCommonAppBase(assemblies));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCommonAppBase_TwoElements_DifferentDirectories()
|
||||
{
|
||||
string[] assemblies = new string[] { path1, path3 };
|
||||
|
||||
Assert.AreEqual(
|
||||
TestPath("/test"),
|
||||
DomainManager.GetCommonAppBase(assemblies));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetCommonAppBase_ThreeElements_DiferentDirectories()
|
||||
{
|
||||
string[] assemblies = new string[] { path1, path2, path3 };
|
||||
|
||||
Assert.AreEqual(
|
||||
TestPath("/test"),
|
||||
DomainManager.GetCommonAppBase(assemblies));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UnloadUnloadedDomain()
|
||||
{
|
||||
AppDomain domain = AppDomain.CreateDomain("DomainManagerTests-domain");
|
||||
AppDomain.Unload(domain);
|
||||
|
||||
DomainManager manager = new DomainManager();
|
||||
manager.Unload(domain);
|
||||
}
|
||||
|
||||
[Test, Platform("Linux,Net", Reason = "get_SetupInformation() fails on Windows+Mono")]
|
||||
public void AppDomainSetUpCorrect()
|
||||
{
|
||||
ServiceContext context = new ServiceContext();
|
||||
context.Add(new SettingsService());
|
||||
var domainManager = new DomainManager();
|
||||
context.Add(domainManager);
|
||||
context.ServiceManager.InitializeServices();
|
||||
|
||||
string mockDll = MockAssembly.AssemblyPath;
|
||||
AppDomainSetup setup = domainManager.CreateAppDomainSetup(new TestPackage(mockDll));
|
||||
|
||||
Assert.That(setup.ApplicationName, Is.StringStarting("Tests_"));
|
||||
Assert.That(setup.ApplicationBase, Is.SamePath(Path.GetDirectoryName(mockDll)), "ApplicationBase");
|
||||
Assert.That(
|
||||
Path.GetFileName( setup.ConfigurationFile ),
|
||||
Is.EqualTo("mock-assembly.dll.config").IgnoreCase,
|
||||
"ConfigurationFile");
|
||||
Assert.AreEqual( null, setup.PrivateBinPath, "PrivateBinPath" );
|
||||
Assert.That(setup.ShadowCopyDirectories, Is.SamePath(Path.GetDirectoryName(mockDll)), "ShadowCopyDirectories" );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take a valid Linux filePath and make a valid windows filePath out of it
|
||||
/// if we are on Windows. Change slashes to backslashes and, if the
|
||||
/// filePath starts with a slash, add C: in front of it.
|
||||
/// </summary>
|
||||
private static string TestPath(string path)
|
||||
{
|
||||
if (Path.DirectorySeparatorChar != '/')
|
||||
{
|
||||
path = path.Replace('/', Path.DirectorySeparatorChar);
|
||||
if (path[0] == Path.DirectorySeparatorChar)
|
||||
path = "C:" + path;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,264 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2007 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
namespace NUnit.Engine.Services.Tests
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Microsoft.Win32;
|
||||
using NUnit.Engine.Internal;
|
||||
using NUnit.Framework;
|
||||
|
||||
/// <summary>
|
||||
/// This fixture is used to test both RecentProjects and
|
||||
/// its base class RecentFiles. If we add any other derived
|
||||
/// classes, the tests should be refactored.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class RecentFilesTests
|
||||
{
|
||||
private const int MAX = 24;
|
||||
private const int MIN = 0;
|
||||
private const int DEFAULT = 5;
|
||||
|
||||
RecentFilesService recentFiles;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
var services = new ServiceContext();
|
||||
services.Add(new Services.SettingsService());
|
||||
recentFiles = new RecentFilesService();
|
||||
services.Add(recentFiles);
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
// Set RecentFiles to a list of known values up
|
||||
// to a maximum. Most recent will be "1", next
|
||||
// "2", and so on...
|
||||
private void SetMockValues( int count )
|
||||
{
|
||||
for( int num = count; num > 0; --num )
|
||||
recentFiles.SetMostRecent( num.ToString() );
|
||||
}
|
||||
|
||||
// Check that the list is set right: 1, 2, ...
|
||||
private void CheckMockValues( int count )
|
||||
{
|
||||
var files = recentFiles.Entries;
|
||||
Assert.AreEqual( count, files.Count, "Count" );
|
||||
|
||||
for( int index = 0; index < count; index++ )
|
||||
Assert.AreEqual( (index + 1).ToString(), files[index], "Item" );
|
||||
}
|
||||
|
||||
// Check that we can add count items correctly
|
||||
private void CheckAddItems( int count )
|
||||
{
|
||||
SetMockValues( count );
|
||||
Assert.AreEqual( "1", recentFiles.Entries[0], "RecentFile" );
|
||||
|
||||
CheckMockValues( Math.Min( count, recentFiles.MaxFiles ) );
|
||||
}
|
||||
|
||||
// Check that the list contains a set of entries
|
||||
// in the order given and nothing else.
|
||||
private void CheckListContains( params int[] item )
|
||||
{
|
||||
var files = recentFiles.Entries;
|
||||
Assert.AreEqual( item.Length, files.Count, "Count" );
|
||||
|
||||
for( int index = 0; index < files.Count; index++ )
|
||||
Assert.AreEqual( item[index].ToString(), files[index], "Item" );
|
||||
}
|
||||
#endregion
|
||||
|
||||
[Test]
|
||||
public void CountDefault()
|
||||
{
|
||||
Assert.AreEqual( DEFAULT, recentFiles.MaxFiles );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountOverMax()
|
||||
{
|
||||
recentFiles.MaxFiles = MAX + 1;
|
||||
Assert.AreEqual( MAX, recentFiles.MaxFiles );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountUnderMin()
|
||||
{
|
||||
recentFiles.MaxFiles = MIN - 1;
|
||||
Assert.AreEqual( MIN, recentFiles.MaxFiles );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountAtMax()
|
||||
{
|
||||
recentFiles.MaxFiles = MAX;
|
||||
Assert.AreEqual( MAX, recentFiles.MaxFiles );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountAtMin()
|
||||
{
|
||||
recentFiles.MaxFiles = MIN;
|
||||
Assert.AreEqual( MIN, recentFiles.MaxFiles );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EmptyList()
|
||||
{
|
||||
Assert.IsNotNull( recentFiles.Entries, "Entries should never be null" );
|
||||
Assert.AreEqual( 0, recentFiles.Entries.Count );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddSingleItem()
|
||||
{
|
||||
CheckAddItems( 1 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddMaxItems()
|
||||
{
|
||||
CheckAddItems( 5 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AddTooManyItems()
|
||||
{
|
||||
CheckAddItems( 10 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IncreaseSize()
|
||||
{
|
||||
recentFiles.MaxFiles = 10;
|
||||
CheckAddItems( 10 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReduceSize()
|
||||
{
|
||||
recentFiles.MaxFiles = 3;
|
||||
CheckAddItems( 10 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IncreaseSizeAfterAdd()
|
||||
{
|
||||
SetMockValues(5);
|
||||
recentFiles.MaxFiles = 7;
|
||||
recentFiles.SetMostRecent( "30" );
|
||||
recentFiles.SetMostRecent( "20" );
|
||||
recentFiles.SetMostRecent( "10" );
|
||||
CheckListContains( 10, 20, 30, 1, 2, 3, 4 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReduceSizeAfterAdd()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.MaxFiles = 3;
|
||||
CheckMockValues( 3 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReorderLastProject()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.SetMostRecent( "5" );
|
||||
CheckListContains( 5, 1, 2, 3, 4 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReorderSingleProject()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.SetMostRecent( "3" );
|
||||
CheckListContains( 3, 1, 2, 4, 5 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReorderMultipleProjects()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.SetMostRecent( "3" );
|
||||
recentFiles.SetMostRecent( "5" );
|
||||
recentFiles.SetMostRecent( "2" );
|
||||
CheckListContains( 2, 5, 3, 1, 4 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReorderSameProject()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.SetMostRecent( "1" );
|
||||
CheckListContains( 1, 2, 3, 4, 5 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReorderWithListNotFull()
|
||||
{
|
||||
SetMockValues( 3 );
|
||||
recentFiles.SetMostRecent( "3" );
|
||||
CheckListContains( 3, 1, 2 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveFirstProject()
|
||||
{
|
||||
SetMockValues( 3 );
|
||||
recentFiles.Remove("1");
|
||||
CheckListContains( 2, 3 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveOneProject()
|
||||
{
|
||||
SetMockValues( 4 );
|
||||
recentFiles.Remove("2");
|
||||
CheckListContains( 1, 3, 4 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveMultipleProjects()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.Remove( "3" );
|
||||
recentFiles.Remove( "1" );
|
||||
recentFiles.Remove( "4" );
|
||||
CheckListContains( 2, 5 );
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveLastProject()
|
||||
{
|
||||
SetMockValues( 5 );
|
||||
recentFiles.Remove("5");
|
||||
CheckListContains( 1, 2, 3, 4 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
// ***********************************************************************
|
||||
// Copyright (c) 2013 Charlie Poole
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ***********************************************************************
|
||||
|
||||
using System.Xml;
|
||||
|
||||
namespace NUnit.Engine.Tests
|
||||
{
|
||||
using Framework;
|
||||
using Internal;
|
||||
|
||||
[TestFixture]
|
||||
public class TestEngineResultTests
|
||||
{
|
||||
private static readonly string xmlText = "<test-assembly result=\"Passed\" total=\"23\" passed=\"23\" failed=\"0\" inconclusive=\"0\" skipped=\"0\" asserts=\"40\" />";
|
||||
|
||||
[Test]
|
||||
public void CanCreateFromXmlString()
|
||||
{
|
||||
TestEngineResult result = new TestEngineResult(xmlText);
|
||||
Assert.True(result.IsSingle);
|
||||
Assert.That(result.Xml.Name, Is.EqualTo("test-assembly"));
|
||||
Assert.That(result.Xml.Attributes["result"].Value, Is.EqualTo("Passed"));
|
||||
Assert.That(result.Xml.Attributes["total"].Value, Is.EqualTo("23"));
|
||||
Assert.That(result.Xml.Attributes["passed"].Value, Is.EqualTo("23"));
|
||||
Assert.That(result.Xml.Attributes["failed"].Value, Is.EqualTo("0"));
|
||||
Assert.That(result.Xml.Attributes["inconclusive"].Value, Is.EqualTo("0"));
|
||||
Assert.That(result.Xml.Attributes["skipped"].Value, Is.EqualTo("0"));
|
||||
Assert.That(result.Xml.Attributes["asserts"].Value, Is.EqualTo("40"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CanCreateFromXmlNode()
|
||||
{
|
||||
XmlNode node = XmlHelper.CreateTopLevelElement("test-assembly");
|
||||
XmlHelper.AddAttribute(node, "result", "Passed");
|
||||
XmlHelper.AddAttribute(node, "total", "23");
|
||||
XmlHelper.AddAttribute(node, "passed", "23");
|
||||
XmlHelper.AddAttribute(node, "failed", "0");
|
||||
XmlHelper.AddAttribute(node, "inconclusive", "0");
|
||||
XmlHelper.AddAttribute(node, "skipped", "0");
|
||||
XmlHelper.AddAttribute(node, "asserts", "40");
|
||||
|
||||
TestEngineResult result = new TestEngineResult(node);
|
||||
Assert.True(result.IsSingle);
|
||||
Assert.That(result.Xml.OuterXml, Is.EqualTo(xmlText));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0"?>
|
||||
<project name="NUnit.Engine.Tests" default="build" basedir=".">
|
||||
|
||||
<patternset id="source-files">
|
||||
<include name="*.cs" />
|
||||
<include name="Api/*.cs" />
|
||||
<include name="Internal/*.cs"/>
|
||||
<include name="Services/*.cs"/>
|
||||
</patternset>
|
||||
|
||||
<target name="build">
|
||||
|
||||
<csc target="library"
|
||||
output="${current.build.dir}/nunit.engine.tests.dll"
|
||||
debug="${build.debug}"
|
||||
define="${build.defines}"
|
||||
warninglevel="${warn}">
|
||||
<sources basedir=".">
|
||||
<include name="../CommonAssemblyInfo.cs" />
|
||||
<patternset refid="source-files" />
|
||||
</sources>
|
||||
<references basedir="${current.build.dir}">
|
||||
<include name="System.Drawing.dll" />
|
||||
<include name="System.Runtime.Remoting.dll" />
|
||||
<include name="nunit.framework.dll" />
|
||||
<include name="nunit.engine.dll" />
|
||||
<include name="nunit.engine.api.dll" />
|
||||
<include name="mock-assembly.dll" />
|
||||
</references>
|
||||
</csc>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="package">
|
||||
<copy todir="${package.src.dir}/nunit.engine.tests">
|
||||
<fileset>
|
||||
<patternset refid="source-files" />
|
||||
<include name="*.build" />
|
||||
<include name="*.csproj" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче