Search Unity

How unit test works in Cloud Build?

Discussion in 'Unity Build Automation' started by chatpongs, Jul 1, 2017.

  1. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
    I have some tests setup in my project and they can be run successfully on my local machine. On Unity Cloud Build, the Tests tab shows nothing like in the picture attached.

    I also do not understand how UnityTest.Batch.RunUnitTests works. Would it run all methods with [Test] attribute? I have a very simple test

    Code (CSharp):
    1. public class UnitTest
    2. {
    3.   [Test]
    4.   public static void AlwaysPass()
    5.   {
    6.     Assert.That(true);
    7.   }
    8. }
    nothing shows up in the Tests tab
     

    Attached Files:

    ModLunar likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    The default test runner should run all the unit tests in the project (marked with [Test]). I am not sure what it looks like though in the cloud build dashboard... maybe it doesn't show up as anything ? (or only if the tests fail)
     
  3. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
    @liortal Thanks for your answer. Anyway, even I setup a test that should fail, the Tests tab is still empty.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    not sure it matters, but i don't know if it runs tests in static methods
     
  5. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
    Both static and non-static test methods work fine in local editor as I have tried. However, both result in an empty Test tab in Cloud Build
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    just tried it, works for us...
    upload_2017-7-2_12-2-29.png
     
  7. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
    Is it possible for you to give me a sample project?
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    no, i am sorry but this is a commercial project owned by my company. i could have a look at yours, if you like (either you can share a few tests, or i can connect to you to have a look).
     
  9. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
    Sorry, I didn't mean that. Just a blank project with only an always-pass test is enough.

    Anyway, I have created a git repo here https://github.com/chatpongs/cloud-build-unit-test. Cloud build stills give me an empty test result (my build target is Android). Could you please have a look and see what is wrong with my setup?

    I really appreciate your help
     
  10. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Looks like a bug in the cloud build dashboard UI? getting this every time i switch to the "Tests" tab.
    CC: @dannyd
     
  11. chatpongs

    chatpongs

    Joined:
    Mar 2, 2015
    Posts:
    24
  12. MikeITS

    MikeITS

    Joined:
    Apr 3, 2015
    Posts:
    5
    I'm encountering this problem as well. The tests seem to run correctly, and the build will fail if the tests don't pass. I can also get the test results in XML form. However, the "Tests" tab is completely blank. I spent most of yesterday trying to debug this problem, but I did not find anything that worked. It's good to know it's not just me though!

    Things I tried:
    • Chrome and Internet Explorer.
    • Using the "Unity Test Tools" package from the asset store, rather than the built-in NUnit.
    • Clean build.
    • Adding/removing NSubstitute, and switching which directory it is in.
    • Setting the version of Unity that the build server should use. I tried the latest version available, as well as the version I have installed locally (v5.6.0f3).
     
    Last edited: Jul 6, 2017
  13. dannyd

    dannyd

    Unity Technologies

    Joined:
    Jun 3, 2014
    Posts:
    785
    Thanks for the heads up! Will get this fixed up soon.
     
    ModLunar and MikeITS like this.
  14. MikeITS

    MikeITS

    Joined:
    Apr 3, 2015
    Posts:
    5
    It seems to work now. Thank you for fixing this issue!
     
  15. RaventurnStefan

    RaventurnStefan

    Joined:
    Aug 1, 2012
    Posts:
    44
    The tests tab is still empty for me. Run Unit Tests is set to true.

    I also tried calling the build status API and I could also get the link to the 'test_data/unit_tests.xml' and all of my tests were running successfully.
     
    Last edited: Aug 28, 2017
  16. saiichihashimoto

    saiichihashimoto

    Joined:
    Apr 18, 2017
    Posts:
    5
    I am having the same problem.
     
  17. mrsln

    mrsln

    Joined:
    Mar 12, 2017
    Posts:
    1
    The issue occurs with my setup as well.
     
  18. erlioniel

    erlioniel

    Joined:
    Aug 31, 2015
    Posts:
    8
    Problem is still actual
     
  19. Matt-HitIQ

    Matt-HitIQ

    Joined:
    Feb 15, 2019
    Posts:
    7
    Hi all was this resolved? Whats the best practice when writing the tests - Separate folder? Specifically names?

    Cheers
     
  20. erdemsahinardentblue

    erdemsahinardentblue

    Joined:
    Dec 3, 2019
    Posts:
    6
    I could not even locate the test tab. Any ideas where i can see it ?
     
  21. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    I'm considering getting Unity Cloud Build..

    But this is pretty important to me, if I got it.
    Maybe I'll try the free trial to test haha.