TBD
- Create a new test class that inherits from VisualTestsBase
- Initialize the visual tests using
VisualTestsBase.InitVisualTestsScene(string)
passing the test name as parameter - Setup your scene as wanted and call
TestHelpers.TakeSnapshot(Vector3)
- Tag the method with the attribute
[VisualTest]
. This isn't used yet but will be used to streamline the baseline images creation.
The pngs will be named automatically using the InitVisualTestsScene
parameter.
Example:
public class VisualTests : VisualTestsBase
{
[UnityTest][VisualTest]
public IEnumerator VisualTestStub()
{
yield return InitVisualTestsScene("VisualTestStub");
// Set up scene
yield return VisualTestHelpers.TakeSnapshot(new Vector3(10f, 10f, 0f));
}
}
- Create a new test inside the same class of the desired visual test. Give it the same name followed by
_Generate
. - call
VisualTestHelpers.GenerateBaselineForTest(IEnumerator)
inside the method, passing the actual test method as parameter. - remember to make the test
[Explicit]
or the test will give false positives
Example:
[UnityTest][Explicit]
public IEnumerator VisualTestStub_Generate()
{
yield return VisualTestHelpers.GenerateBaselineForTest(VisualTestStub());
}