Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Streaming Assets and PlayMode Tests

Discussion in 'Unity Cloud Build' started by AlexNanomonx, Nov 27, 2019.

  1. AlexNanomonx

    AlexNanomonx

    Joined:
    Jan 4, 2017
    Posts:
    35
    So we've been trying to add some tests to our project, to increase stability, prevent regression etc. etc. We also use Asset Bundles and specifically Streaming Assets. At the moment the order of operations in CloudBuild is, as far as I can work out.
    1. Setup
    2. Tests
    3. Build Asset Bundle
    4. Copy to StreamingAssets
    5. Build project
    In our project if the StreamingAssets aren't present then play mode cannot run, consequently our PlayMode tests can't run. Is there a way to make the tests run later or resolve this issue?

    I had the idea of creating an edit mode test, which secretly just builds and copies the StreamingAssets, which you can't do in PlayMode.

    Can anyone who understands the CloudBuild properly think of a less hacky way to do this?
     
  2. AlexNanomonx

    AlexNanomonx

    Joined:
    Jan 4, 2017
    Posts:
    35
    Just finished my tests of this and this works:

    1. Create an EditMode test where no test are are actually performed
    2. From that test build the asset bundles that you need
    3. Copy those asset bundles to the streaming assets folder
    Unity cloud build will run the editmode "test", then the PlayMode tests and everything passes.
     
  3. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    :eek:

    I mean that works I guess? And it's probably the best approach right now, but you absolutely should not have to do that. The order of operations for the build is mostly like that for historical reasons and there's not really any easy way for us to alter it to support this use case without dramatically slowing down the build or doing a major rewrite of build code. That said I'll make sure we have work logged to do that major rewrite and I'll link this forum thread in the ticket, because yeah this should be supported without having to take such a hacky approach.
     
  4. flip_the_unflappable

    flip_the_unflappable

    Joined:
    Jul 9, 2020
    Posts:
    11
    Is this still the case?

    I have some PlayMode tests that rely on StreamingAssets, and the tests fail.
    However, those some test scenarios work fine within a scene.
    Are PlayMode tests able to access the StreamingAssets directory?
     
  5. victorw

    victorw

    Unity Technologies

    Joined:
    Sep 14, 2016
    Posts:
    459
    You can use the approach that @AlexNanomonx mentioned to build StreamingAssets before the tests are run. We are working with the Editor team and have prioritized the rework of the build systems so hopefully later this year it will be possible to support this scenario without any workarounds.
     
unityunity