Skip to content

Conversation

@nowsprinting
Copy link
Owner

@nowsprinting nowsprinting commented Dec 22, 2025

Added

FlipTexture2dEqualityComparer (optional)

FlipTexture2dEqualityComparer is a NUnit test comparer class that compares two Texture2D using FLIP.

Output error map image file if assertion fails.
Default output path is "Application.persistentDataPath/TestHelper/Screenshots/TestContext.Test.Name.diff.png".
You can specify the output directory and/or filename by constructor arguments.
Directory can also be specified by command line argument -testHelperScreenshotDirectory.

Usage:

[TestFixture]
public class MyTestClass
{
    [Test]
    public async Task MyTestMethod()
    {
        await Awaitable.EndOfFrameAsync();
        var actual = ScreenCapture.CaptureScreenshotAsTexture();
        var expected = AssetDatabase.LoadAssetAtPath<Texture2D>(ExpectedImagePath);

        var comparer = new FlipTexture2dEqualityComparer(meanErrorTolerance: 0.01f);
        Assert.That(actual, Is.EqualTo(expected).Using(comparer));
    }
}

Important

FlipTexture2dEqualityComparer is an optional functionality. To use it, you need to install the FlipBinding.CSharp NuGet package v1.0.0 or newer.
Also, add scripting define symbol ENABLE_FLIP_BINDING if not installed via OpenUPM (UnityNuGet).

@github-actions github-actions bot added the enhancement New feature or request label Dec 22, 2025
@github-actions

This comment has been minimized.

@github-actions
Copy link

Code Metrics Report

master (35345dc) #178 (8cda137) +/-
Coverage 79.4% 79.4% 0.0%
Code to Test Ratio 1:1.0 1:1.0 -0.1
Test Execution Time 8m8s 5m18s -2m50s
Details
  |                     | master (35345dc) | #178 (8cda137) |  +/-   |
  |---------------------|------------------|----------------|--------|
  | Coverage            |            79.4% |          79.4% |   0.0% |
  |   Files             |               44 |             44 |      0 |
  |   Lines             |             1581 |           1581 |      0 |
  |   Covered           |             1256 |           1256 |      0 |
- | Code to Test Ratio  |            1:1.0 |          1:1.0 |   -0.1 |
  |   Code              |             2773 |           2917 |   +144 |
+ |   Test              |             2968 |           3096 |   +128 |
+ | Test Execution Time |             8m8s |          5m18s | -2m50s |

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants