Search Unity

Package with playmode test assembly not being recognized

Discussion in 'Package Manager' started by THAMATRIX, Feb 10, 2021.

  1. THAMATRIX

    THAMATRIX

    Joined:
    Sep 6, 2018
    Posts:
    10
    Hello everyone,

    After creating some playmode tests inside my project and them working fine I tried creating a package of my runtime code + my tests. After adding my custom package from disk using the unity package manager I tried testing again. It seems that PlayMode tests are not possible but Editor tests are. In addition, when I dragged my tests back into the project folder the tests where recognized again.

    This is what my assembly definition looks like:
    Code (JavaScript):
    1. {
    2.     "name": "Unity.MyPackage.Runtime.Tests",
    3.     "references": [
    4.         "UnityEngine.TestRunner",
    5.         "UnityEditor.TestRunner",
    6.         "Unity.MyPackage.Runtime"
    7.     ],
    8.     "includePlatforms": [],
    9.     "excludePlatforms": [],
    10.     "allowUnsafeCode": false,
    11.     "overrideReferences": true,
    12.     "precompiledReferences": [
    13.         "nunit.framework.dll"
    14.     ],
    15.     "autoReferenced": false,
    16.     "defineConstraints": [
    17.         "UNITY_INCLUDE_TESTS"
    18.     ],
    19.     "versionDefines": [],
    20.     "noEngineReferences": false
    21. }
     
  2. THAMATRIX

    THAMATRIX

    Joined:
    Sep 6, 2018
    Posts:
    10
    Already fixed the problem. This thread can be closed.
     
  3. Zechy

    Zechy

    Joined:
    Nov 10, 2016
    Posts:
    22
    How did you solved it?
     
  4. THAMATRIX

    THAMATRIX

    Joined:
    Sep 6, 2018
    Posts:
    10
    You are required to create a specific setup for Runtime Assemblies to work.

    General

    Make sure “Auto Referenced” and “Override References” flags are set.

    Define Constraints

    Make sure no constraint called UNITY_INCLUDE_TESTS is part of this list.

    Platforms

    Set the “any platforms” flag. Furthermore, exclude all potential build targets you might use. You can't mention any platforms that might not exist on other versions (i.e. Game Core - Scarlett, Cloud Rendering, etc.) while the ones that we do use should be excluded.

    Example:
    upload_2021-6-5_17-38-47.png