Search Unity

Resolved Unity Test Runner and CI

Discussion in 'Testing & Automation' started by Nigey, Apr 19, 2017.

  1. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    Hi Guys,

    I'm in love with the Unity Test Runner. Being able to use unit testing with timed events is amazing. I want to set up continuous integration. I can use simple NUnit with TeamCity for CI, however I want to ideally use the timed events in the Unity Test Runner. Is there a way?

    Thanks!
     
  2. Laurens109

    Laurens109

    Joined:
    Apr 15, 2017
    Posts:
    26
    Well, I don't know much about TeamCity CI, but I think you should something like this:

    1. Setup TeamCity CI
    2. Setup a TeamCity project for running the tests, which executes commandline code that looks like this:

    _________________________________________
    >Unity.exe
    -projectPath PATH_TO_YOUR_PROJECT
    -runEditorTests [/code]
    _________________________________________

    More about --> https://docs.unity3d.com/Manual/testing-editortestsrunner.html

    3. Setup some projects for building the games for the different platforms, which also executes commandline code that looks like this:
    _________________________________________

    "C:\Program Files\Unity\Editor\Unity.exe" -quit -batchmode -serial SB-XXXX-XXXX-XXXX-XXXX-XXXX -username "JoeBloggs@example.com" -password "MyPassw0rd"
    _________________________________________

    More about Unity build commands (and other command line commands) --> https://docs.unity3d.com/Manual/CommandLineArguments.html


    More info at: https://docs.unity3d.com/Manual/testing-editortestsrunner.html
     
    Nigey likes this.
  3. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    Could not be more helpful, thank you.
     
  4. dtretyakov

    dtretyakov

    Joined:
    Dec 19, 2018
    Posts:
    2
    Nigey likes this.
  5. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    We are actually using TeamCity for building our game clients as well as running tests for some time (PlayMode, Edit Mode).

    If you need any help give me a shout !
     
    LeonhardP and Nigey like this.
  6. mikegoh97

    mikegoh97

    Joined:
    Jan 30, 2017
    Posts:
    1
    Hi @liortal,

    My team and I are trying to setup TeamCity to do our builds and run tests. I was wondering if you could answer a few questions:
    1. what are your thoughts on TeamCity vs other CIs i.e. Jenkins?
    2. How did your team set up TeamCity to run tests and builds? - not sure what to do besides adding the plugin to TeamCity
    Thanks in advance!
     
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    @mikegoh97 I am the biggest TeamCity fanboy alive !! i love it !

    This would be the 3rd company i am using it in. In the 1st and and in current one i actually set it up from scratch.
    The administration, setup and usage are very simple and friendly. So i can only recommend using TeamCity :)

    For running tests - we simply invoke Unity from the command line, passing the correct options to execute tests (edit mode, play mode).

    I can help you set it up or troubleshoot it, if you like, shoot me a private message here, or email me at: liortal53@gmail.com
     
  8. ab_salazar

    ab_salazar

    Joined:
    Aug 23, 2016
    Posts:
    7
    Hi, could you help me to implement this in Jenkins?

    I am using these commands but when I create a compilation in Jenkins, it stays in loop.

    Unity.exe -runTests -proyectPath C:\Users\Erick\Documents\Bitbucket -runEditorTests\Test -testResults c:\temp\results.xml -testPlatform pc