Skip to content

Video attribute

Viktor edited this page Mar 14, 2017 · 7 revisions

The [Video] attribute is used to trigger recording video for a single test marked with the [Test] Nunit attribute, therefore it can be applied on the test method level only. This attribute and its settings have priority over the [WatchDog] attribute and its settings applied on the class level.

The simplest usage of the [Video] attribute is shown below:

[Test]
[Video]
public void MyTest1()
{
    // your code here
}

or

[Test, Video]
public void MyTest2()
{
    // your code here
}

In the examples above, video will be recorded for each test separately according to the default settings (see below) and saved to the output folder.

The [Video] attribute also has 2 optional properties:

  • the Name property stands for assigning a custom output video file name for a particular test (by default, a test method's name is assigned);
  • the Mode property is designed for specifying a video saving mode for a particular test. There are two possible values of a video saving mode for a test: SaveMe.Always (default value, video will be recorded and saved independently of the test result) and SaveMe.OnlyWhenFailed (video will be saved for failed and inconclusive tests only).

It is possible to specify all or any of these properties for each test method as well as none of them. Here are the examples of the properties usage:

[Test]
[Video(Name = "MyFavouriteTest", Mode = SaveMe.OnlyWhenFailed)]
public void MyTest3()
{
    // your code here
}

[Test, Video(Mode = SaveMe.Always)]
public void MyTest4()
{
    // your code here
}

See the UsageMethodLevelExamples file for more examples of the [Video] attribute usage.

Clone this wiki locally