Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Struggling with assembly references when trying to make a plugin/package with test utils

Discussion in 'Testing & Automation' started by bilalakil, Jan 5, 2022.

  1. bilalakil

    bilalakil

    Joined:
    Jan 28, 2018
    Posts:
    76
    I'm making a package called TestUtils with the following goals:
    - Contains some helper stuff I want multiple of my Unity projects to use/extend for their own tests
    - Supports play mode testing, and in-editor testing (via Test Runner window)
    - Of course, references Nunit

    However there are some problems:
    - The TestUtils assembly is being included in NON-TEST play mode builds, even though Auto Reference is unticked
    - This causes the build to fail because Nunit is not available - it seems to only be available when UNITY_INCLUDE_TESTS is set
    - However, I can't add UNITY_INCLUDE_TESTS to TestUtils because then local project assemblies will fail to include it, removing the Test Runner window support. Somehow assemblies with UNITY_INCLUDE_TESTS never build in-editor for plugins even if I explicitly add this variable under Player Settings - I suspect some of this code is tampering with it

    So I don't see any way to proceed here... How to support play mode testing, Test Runner window testing, and also actual (non-test) play mode at the same time considering the UNITY_INCLUDE_TESTS/Nunit strangeness going on here?