Table of Contents

Class UnitTestBase

The base class of the FTD Visual Studio template classes that are provided when creating a new test project.

Inheritance
UnitTestBase
Namespace: HP.LFT.UnitTesting
Assembly: HP.LFT.UnitTesting.dll
Syntax
public abstract class UnitTestBase : UnitTestSuiteBase
Remarks

This class encapsulates all the functionality related to running tests and creating the HTML report.

Constructors

UnitTestBase()

Declaration
protected UnitTestBase()

Properties

ALM

The default OpenText Application Quality Management data-source for data-driven tests. Use for NUnit 2.6x tests.

Declaration
public IEnumerable<string[]> ALM { get; }
Property Value
Type Description
IEnumerable<string[]>

ALMStatic

The static OpenText Application Quality Management data-source for data-driven tests. Use for NUnit 3.x tests.

Declaration
public static IEnumerable<string[]> ALMStatic { get; }
Property Value
Type Description
IEnumerable<string[]>

Reporter

Returns the Reporter of type IReporter used for reporting events.

Declaration
public IReporter Reporter { get; }
Property Value
Type Description
IReporter

Methods

GetAlternativeClassName()

Returns the alternative Class name that is used whenever framework errors occur.

Declaration
protected virtual string GetAlternativeClassName()
Returns
Type Description
string

The alternative test name.

Remarks

This can be useful to set the start and end points of a class in your project if the runner you are using does not successfully pass class names to the report.

In this case, by default the HTML report displays: [Undefined]. Override to provide an alternative test method name.

GetAlternativeTestName()

Returns the alternative Test name that is used whenever framework errors occur.

Declaration
protected virtual string GetAlternativeTestName()
Returns
Type Description
string

The alternative test name.

Remarks

This can be useful to set the start and end points of a test in your class if the runner you are using does not successfully pass test names to the report.

In this case, by default the report displays: [Undefined]. Override to provide an alternative test method name.

GetClassName()

This method is implemented in FTD Visual Studio templates to get the running class name provided by the selected framework (NUnit/MSTest) TestContext.

Declaration
protected abstract string GetClassName()
Returns
Type Description
string

The running class name.

GetFrameworkTestResult()

This method is implemented in FTD Visual Studio templates to get the running test/class status provided by the selected framework (NUnit/MSTest) TestContext.

Declaration
protected abstract Status GetFrameworkTestResult()
Returns
Type Description
Status

The running test status.

GetTestName()

This method is implemented in FTD Visual Studio templates to get the running test name provided by the selected framework (NUnit/MSTest) TestContext.

Declaration
protected abstract string GetTestName()
Returns
Type Description
string

The running test name.

GetTestParameters()

This method is implemented in FTD Visual Studio template to get the running test parameters provided by MSTest TestContext.

Declaration
protected virtual DataRow GetTestParameters()
Returns
Type Description
DataRow

The running test parameters.

TestSetUp()

This method is called by FTD Visual Studio templates' BasicSetUp, which runs before each test method.

Declaration
protected void TestSetUp()

TestSuiteSetup(string)

This method is called by FTD Visual Studio templates' GlobalSetup to initialize the test class.

Declaration
protected override void TestSuiteSetup(string frameworkWorkDir = null)
Parameters
Type Name Description
string frameworkWorkDir
Overrides
UnitTestSuiteBase.TestSuiteSetup(string)

TestTearDown()

This method is called by FTD Visual Studio templates' BasicTearDown, which runs after each test method.

Declaration
protected void TestTearDown()