Search Unity

Unity Extending Unity Test Framework

Discussion in 'Testing & Automation' started by Warnecke, Aug 7, 2019.

  1. Warnecke

    Warnecke

    Unity Technologies

    Joined:
    Nov 28, 2017
    Posts:
    27
    In version 1.1.0 of the Unity Test Framework (UTF) we have introduced multiple ways of extending the UTF functionality to help you customize the framework to suit your CI needs.

    We have gathered some of the ways that UTF can be extended in our documentation here: https://docs.unity3d.com/Packages/com.unity.test-framework@1.1/manual/extending.html

    One of the bigger changes is the TestRunnerApi. This allows for running tests programmatically from code running in the Unity editor. You can also get the test list on beforehand and get callbacks with test results.

    One extension we have added is the ability to customize the build settings when building the player for tests. It is possible to combine this with callbacks on the player to split the building of the player and running the tests. This is especially useful when you want to run tests on a device, as you can avoid blocking that device while building the player. You can then also customize the way that you report back the test results. .

    See the documentation on the callbacks here: https://docs.unity3d.com/Packages/c...tml#split-build-and-run-for-player-mode-tests

    Some minor improvements include new edit mode yield commands for recompiling scripts and for waiting for a domain reload.
     
    liortal likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    I think I asked this before but trying again - will this ITF package support 2018.4 versions as well?

    We only recently upgraded and it is a process we don't do so often. I would love to benefit from the test framework updates as well.
     
  3. Warnecke

    Warnecke

    Unity Technologies

    Joined:
    Nov 28, 2017
    Posts:
    27
    I am afraid not. It is not possible for us to backport the full package to 2018.4, as it would collide with the build in version. There is currently no plans for backporting the TestRunnerApi to 2018.4 either.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    Does the package come in source code format?

    If the only problem is colliding with the existing framework (and not relying on some deeper integration with the engine) I could simply change the namespace or something similar.
     
  5. Warnecke

    Warnecke

    Unity Technologies

    Joined:
    Nov 28, 2017
    Posts:
    27
    You could try that. Make a 2019.2 project with the test-framework version you desire and then find the source code inside the PackageCache. You can then move the source inside the Packages folder of e.g. a 2018.4 project.
    In addition to the namespace collisions, you might face some issues with changes to assembly definitions between 2018.4 and 2019.2.
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    Sounds simple enough. I can post it later to gain instant internet fame!
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    @Warnecke turns out it is not that simple
    upload_2019-8-8_22-7-18.png
    As i thought, the test framework probably has some deeper dependencies on class introduces in newer Unity versions (DeploymentTargetLogger?) so it will not even compile on Unity 2018.4.