Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added namespace/class/method args for xunit2 #1180

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 52 additions & 13 deletions src/app/FakeLib/UnitTest/XUnit/XUnit2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,53 @@ open System.Text
open Fake

(*
xUnit.net console test runner (64-bit .NET 4.0.30319.34209)
Copyright (C) 2014 Outercurve Foundation.
xUnit.net Console Runner (64-bit .NET 4.0.30319.17020)
Copyright (C) 2015 Outercurve Foundation.

usage: xunit.console <assemblyFile> [configFile] [options]
usage: xunit.console <assemblyFile> [configFile] [assemblyFile [configFile]...] [options] [reporter] [resultFormat filename [...]]

Note: Configuration files must end in .json (for JSON) or .config (for XML)

Valid options:
-nologo : do not show the copyright message
-nocolor : do not output results with colors
-noappdomain : do not use app domains to run test code
-failskips : convert skipped tests into failures
-parallel option : set parallelization based on option
: none - turn off all parallelization
: none - turn off all parallelization
: collections - only parallelize collections
: assemblies - only parallelize assemblies
: all - parallelize assemblies & collections
: assemblies - only parallelize assemblies
: all - parallelize assemblies & collections
-maxthreads count : maximum thread count for collection parallelization
: 0 - run with unbounded thread count
: >0 - limit task thread pool size to 'count'
-silent : do not output running test count
: default - run with default (1 thread per CPU thread)
: unlimited - run with unbounded thread count
: (number) - limit task thread pool size to 'count'
-noshadow : do not shadow copy assemblies
-teamcity : forces TeamCity mode (normally auto-detected)
-appveyor : forces AppVeyor CI mode (normally auto-detected)
-wait : wait for input after completion
-diagnostics : enable diagnostics messages for all test assemblies
-debug : launch the debugger to debug the tests
-serialize : serialize all test cases (for diagnostic purposes only)
-trait "name=value" : only run tests with matching name/value traits
: if specified more than once, acts as an OR operation
-notrait "name=value" : do not run tests with matching name/value traits
: if specified more than once, acts as an AND operation
-method "name" : run a given test method (should be fully specified;
: i.e., 'MyNamespace.MyClass.MyTestMethod')
: if specified more than once, acts as an OR operation
-class "name" : run all methods in a given test class (should be fully
: specified; i.e., 'MyNamespace.MyClass')
: if specified more than once, acts as an OR operation
-namespace "name" : run all methods in a given namespace (i.e.,
: 'MyNamespace.MySubNamespace')
: if specified more than once, acts as an OR operation

Reporters: (optional, choose only one)
-appveyor : forces AppVeyor CI mode (normally auto-detected)
-quiet : do not show progress messages
-teamcity : forces TeamCity mode (normally auto-detected)
-verbose : show verbose progress messages

Result formats: (optional, choose one or more)
-xml <filename> : output results to xUnit.net v2 style XML file
-xmlv1 <filename> : output results to xUnit.net v1 style XML file
-nunit <filename> : output results to NUnit-style XML file
Expand Down Expand Up @@ -105,7 +128,14 @@ type XUnit2Params =
/// Forces AppVeyor CI mode (normally auto-detected).
ForceAppVeyor : bool
/// Waits for input after completion.
Wait : bool }
Wait : bool
/// Run xUnit against a specific namespace
Namespace : string option
/// Run xUnit against a specific class
Class : string option
/// Run xUnit against a specific method
Method : string option
}

/// The xUnit2 default parameters.
///
Expand All @@ -128,6 +158,9 @@ type XUnit2Params =
/// - `ForceAppVeyor` - `false`
/// - `Silent` - `false`
/// - `Wait` - `false`
/// - `Namespace` - `None`
/// - `Class` - `None`
/// - `Method` - `None`
let XUnit2Defaults =
{ NoAppDomain = false
Parallel = NoParallelization
Expand All @@ -146,7 +179,10 @@ let XUnit2Defaults =
ForceTeamCity = false
ForceAppVeyor = false
Silent = false
Wait = false }
Wait = false
Namespace = None
Class = None
Method = None }

let buildXUnit2Args assemblies parameters =
let formatTrait traitFlag (name, value) =
Expand All @@ -172,6 +208,9 @@ let buildXUnit2Args assemblies parameters =
|> appendIfSome parameters.HtmlOutputPath (sprintf @"-html ""%s""")
|> appendTraits parameters.IncludeTraits "-trait"
|> appendTraits parameters.ExcludeTraits "-notrait"
|> appendIfSome parameters.Namespace (sprintf @"-namespace ""%s""")
|> appendIfSome parameters.Class (sprintf @"-class ""%s""")
|> appendIfSome parameters.Method (sprintf @"-method ""%s""")
|> toText

/// Helper method to detect if the xunit console runner supports the -noappdomain flag.
Expand Down
30 changes: 24 additions & 6 deletions src/test/Test.FAKECore/XUnit2Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ internal class When_using_parameters_which_include_traits
Util.Traits(Util.Trait("name", "value3")),
XUnit2.XUnit2Defaults.ForceTeamCity,
XUnit2.XUnit2Defaults.ForceAppVeyor,
XUnit2.XUnit2Defaults.Wait);
XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
};

It should_include_the_expected_include_trait_arguments = () =>
Expand Down Expand Up @@ -134,7 +137,10 @@ internal class When_using_parameters_which_include_reports
XUnit2.XUnit2Defaults.ExcludeTraits,
XUnit2.XUnit2Defaults.ForceTeamCity,
XUnit2.XUnit2Defaults.ForceAppVeyor,
XUnit2.XUnit2Defaults.Wait);
XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
};

It should_include_the_expected_HTML_reporting_argument = () =>
Expand Down Expand Up @@ -173,7 +179,10 @@ internal class When_using_parameters_which_request_total_parallel_execution
XUnit2.XUnit2Defaults.ExcludeTraits,
XUnit2.XUnit2Defaults.ForceTeamCity,
XUnit2.XUnit2Defaults.ForceAppVeyor,
XUnit2.XUnit2Defaults.Wait);
XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
};

It should_include_the_expected_parallel_argument = () =>
Expand Down Expand Up @@ -206,7 +215,10 @@ internal class When_using_parameters_which_request_assembly_only_parallel_execut
XUnit2.XUnit2Defaults.ExcludeTraits,
XUnit2.XUnit2Defaults.ForceTeamCity,
XUnit2.XUnit2Defaults.ForceAppVeyor,
XUnit2.XUnit2Defaults.Wait);
XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
};

It should_include_the_expected_parallel_argument = () =>
Expand Down Expand Up @@ -239,7 +251,10 @@ internal class When_using_parameters_which_request_collection_only_parallel_exec
XUnit2.XUnit2Defaults.ExcludeTraits,
XUnit2.XUnit2Defaults.ForceTeamCity,
XUnit2.XUnit2Defaults.ForceAppVeyor,
XUnit2.XUnit2Defaults.Wait);
XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
Assemblies = new[] { "test.dll", "other.dll" };
};

Expand Down Expand Up @@ -273,7 +288,10 @@ internal class When_using_parameters_which_request_non_default_flags
XUnit2.XUnit2Defaults.ExcludeTraits,
!XUnit2.XUnit2Defaults.ForceTeamCity,
!XUnit2.XUnit2Defaults.ForceAppVeyor,
!XUnit2.XUnit2Defaults.Wait);
!XUnit2.XUnit2Defaults.Wait,
XUnit2.XUnit2Defaults.Namespace,
XUnit2.XUnit2Defaults.Class,
XUnit2.XUnit2Defaults.Method);
};

It should_request_no_shadow_copy = () =>
Expand Down