Class TestPackage
A TestPackage contains one or more test files. It also holds settings how the tests should be loaded.
Inheritance
Inherited Members
Namespace: NBench.Sdk
Assembly: NBench.dll
Syntax
public class TestPackage
Constructors
TestPackage(IEnumerable<Assembly>, IEnumerable<String>, IEnumerable<String>, Boolean)
Initializes a new package with multiple test files.
Declaration
public TestPackage(IEnumerable<Assembly> assemblies, IEnumerable<string> include = null, IEnumerable<string> exclude = null, bool concurrent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Reflection.Assembly> | assemblies | A list of test files. |
| System.Collections.Generic.IEnumerable<System.String> | include | Optional list of include patterns |
| System.Collections.Generic.IEnumerable<System.String> | exclude | Optional list of exclude patterns |
| System.Boolean | concurrent | Enable benchmarks that use multiple threads. See Concurrent for more details. |
TestPackage(Assembly, IEnumerable<String>, IEnumerable<String>, Boolean)
Initializes a new test package with one test assembly.
Declaration
public TestPackage(Assembly testAssembly, IEnumerable<string> include = null, IEnumerable<string> exclude = null, bool concurrent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Reflection.Assembly | testAssembly | An assembly to test. |
| System.Collections.Generic.IEnumerable<System.String> | include | An optional include pattern |
| System.Collections.Generic.IEnumerable<System.String> | exclude | An optional exclude pattern |
| System.Boolean | concurrent | Enable benchmarks that use multiple threads. See Concurrent for more details. |
Properties
Concurrent
If true, NBench disables any processor affinity or thread priority settings.
If false, NBench will run in single-threaded mode and set processor affinity + thread priority.
Defaults to false.
Declaration
public bool Concurrent { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
ConfigurationFile
Gets or sets a file path to the configuration file (app.config) used for the test assemblies
Declaration
public string ConfigurationFile { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Name
Gets or sets the name of the test package
Declaration
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
OutputDirectory
Gets or sets the directory for the result output file
Declaration
public string OutputDirectory { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
OutputTargets
Additional output targets that will be written to in addition to MarkdownBenchmarkOutput and ConsoleBenchmarkOutput.
Declaration
public IReadOnlyList<IBenchmarkOutput> OutputTargets { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyList<IBenchmarkOutput> |
TeamCity
If true, NBench uses TeamCity formatting for all of its benchmark methods.
If false, NBench uses regular console logging for all of its benchmark methods.
Defaults to false.
Declaration
public bool TeamCity { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
TestAssemblies
Gets the assemblies containing tests
Declaration
public IReadOnlyList<Assembly> TestAssemblies { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IReadOnlyList<System.Reflection.Assembly> |
Tracing
If true, NBench enables tracing and writes its output to all configured output targets.
If false, NBench disables tracing and will not write any output.
Defaults to false.
Declaration
public bool Tracing { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
AddExclude(String)
Add a pattern to be excluded. We'll ignore nulls.
Declaration
public TestPackage AddExclude(string exclude)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | exclude |
Returns
| Type | Description |
|---|---|
| TestPackage |
AddInclude(String)
Add a pattern to be included. We'll ignore nulls.
Declaration
public TestPackage AddInclude(string include)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | include |
Returns
| Type | Description |
|---|---|
| TestPackage |
AddOutput(IBenchmarkOutput)
Declaration
public TestPackage AddOutput(IBenchmarkOutput output)
Parameters
| Type | Name | Description |
|---|---|---|
| IBenchmarkOutput | output |
Returns
| Type | Description |
|---|---|
| TestPackage |
BuildPattern(String)
Converts a wildcard to a regex pattern
Declaration
public static Regex BuildPattern(string pattern)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pattern |
Returns
| Type | Description |
|---|---|
| System.Text.RegularExpressions.Regex |
ShouldRunBenchmark(String)
Declaration
public bool ShouldRunBenchmark(string benchmarkName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | benchmarkName |
Returns
| Type | Description |
|---|---|
| System.Boolean |