Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Test Runner not showing any of my tests

Discussion in 'Package Manager' started by rmenapace, Jan 25, 2019.

  1. rmenapace

    rmenapace

    Joined:
    Jul 12, 2018
    Posts:
    4
    I am trying to create a package with some tests in it, that I would like the projects that use the package to be able to run. I set the folders and assemblies up as described in the docs:

    ... but the tests do not show up in the test runner. Is there something else I need to do to make this work?
     
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
    Hi @menaspace,

    How is your package referred to by the project? If the package is *embedded* or a *local* package, it should show up in the test runner automatically.

    Also, where did you get this doc? It looks to be missing some information.

    Regards,

    Pascal
     
  3. rmenapace

    rmenapace

    Joined:
    Jul 12, 2018
    Posts:
    4
  4. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
    Thanks for sharing. This document is indeed lacking for testing packages. The intention was to give an idea of how a package is structured if you ever looked inside one provided by Unity. We are working on more complete documentation for 2019.1 release in the Unity user manual. The goal of this documentation will be to assist you in creating your custom package.

    Back to helping you. Have you *embedded* the package?

    Pascal
     
  5. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,416
    • and by *embedded* you mean being put inside ProjectFolder/packages?
    • and by *local* ― inside ProjectFolder/Assets?
    • or vice versa?
    • or by *local* means referenced via "Add package from disk"?
    There are too many ways to consume a package. :D
     
  6. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
    Hahaha. Indeed :p

    By *embedded*, I mean the package is physically located under the */Packages* folder
    By *local*, I mean referenced via "Add a package from disk". In the project manifest, the package version value set to a file path like "file:/some/path/"

    In both of these cases, your package tests should automatically show up in the test runner. If they don't, the issue is probably in the test configuration or assembly definition file settings.
     
  7. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,416
    If a custom package is *embedded*, its tests are available in the test runner. If it's *added from disk*, they are not. Can it be a configuration problem? I thought it's a feature.
     
  8. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
  9. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,416
    I don't see it as a bug. Packages *added from disk* behave the same way packages referenced from the registry do.

    If I want to customize a package and test the changes and/or add new tests, I do it in the *embedded* local copy. Seems reasonable, unless I misunderstand the purpose of these locally referenced packages. I treat them as released, not as work-in-progress ones.

    I also don't want *added from disk* packages to spam my VS solution with their test projects. Right now they don't. However I do realize that being included in the solution is not the same thing as being available in the test runner.
     
  10. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
    @alexzzzz , It is hard to meet everyone's expectation. They are a lot of users developing their packages using the
    file:
    project dependency. In 2019.2, we will support local package tarballs. Those will be defined as immutable (i.e. tests won't show up in the tests runner). You could use this way of introducing local packages in your project when available. The only requirement will be to tar the package folder. Hope this will resolve your issue!

    Regards,

    Pascal
     
    jorgegalvaominiclip likes this.
  11. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    721
    Going back to this thread after a long time! I just realized that I made a mistake. Only *embedded* packages are automatically set as visible in the test runner. To make a *local* package visible in the test runner, you need to manually make the package *testable* . You can do so by adding a new
    testables
    attribute in the project manifest (Packages/manifest.json).

    Ex:

    Code (JavaScript):
    1. {
    2.   "dependencies": {
    3.     "a": "file:/some/path"
    4.   },
    5.   "testables" : ["a"]
    6. }
    Regards,

    Pascal
     
    zhouwensi likes this.
  12. zhouwensi

    zhouwensi

    Joined:
    Feb 13, 2020
    Posts:
    1
    Thanks, it works , carefull that add testables to project manifest (Packages/manifest.json), not the package json file.
     
    pocketandrew likes this.
  13. vestigial

    vestigial

    Joined:
    May 9, 2015
    Posts:
    155
    I'm encountering something weird, if I use a custom test attribute from a git package (so, not an embedded package, nor a local package), the test only shows up if it contains an Assert.

    Using [UnityTest], the test shows up regardless of if it has any asserts in it.
    Using [CustomTest], which derives from [UnityTest] and implements [IOuterUnityTestAction], the test doesn't show up if contains only a yield return true, and no Assert. I can write up a proper bug report if that'd be useful
     
unityunity