Course Content : Test Driven Development

Hi all,

A little bit of information relating to the Test Driven Development content for this section of the course.

This section used an asset from the Unity Asset Store called Unity Test Tools. During 2017 this asset was removed, and as such, the directions within a lecture, preceding Making Your First Test Pass, to install this asset were no longer possible and the lecture was removed.

Unfortunately, the removed lecture, which covered the installation of the Unity Test Tools asset, also demonstrated the creation of a very basic test script, ScoreMasterTest.cs and it being run within Unity. Remnants of this are visible in the lecture, Making Your First Test Pass where, at 00:21, you can see a pane on the right-hand side of the screen named Unit Tests. This is the output from the very basic test script that was created in the removed lecture.

At 01:08 you can see Ben browses into the Editor folder within Assets to access the ScoreMasterTest.cs script. The Editor folder is a special folder, when scripts are placed in it they are treated as Editor scripts rather than runtime scripts and enable additional functionality to be added to the Unity editor.

At this point in the course, you will not have the Unity Test Tools asset, or the script created in the removed lecture, to work around this issue, for the time being, you can perform the following steps;

  • Take a backup of your project
  • Upgrade to Unity 5.6 / 2017 - this will provide Unity’s Test Runner functionality
  • Create a new folder called Editor within the Assets folder
  • Create a new script called ScoreMasterTest.cs within the Editor folder
  • Replace all of the code within the newly created ScoreMasterTest.cs script with the following;
    using System;
    using System.Collections.Generic;
    using NUnit.Framework;
    using UnityEngine;
    
    [TestFixture]
    public class ScoreTest {
    
    	[Test]
    	public void PassingTest () {
    		Assert.AreEqual (1, 1);
    	}
    }
    
  • Save the script
  • Save the project

Alternatively ScoreMasterTest.zip (316 Bytes) contains the Editor folder and ScoreMasterTest.cs which you can then extract and drag directly into your Assets folder.

You should now be able to continue from 01:08 and follow the steps Ben performs, be aware that the Test Runner pane will look slightly different from the videos but performs the same functionality.

I hope the above is of use and enables you to move forward with the course. :slight_smile:


See also;

13 Likes

Not sure whether it is too late to be of use, but tagging those of you who had experienced issues with this in the hope that it is of help;

@Nicholas_McRae @Veronica_Zemenovich @AvivUziel @Craig_Bodkin

2 Likes

Thank you Rob, this helpful post is now linked from the course in two places.

4 Likes

Kind of late to this here and I did a work around for this, but on Scoremaster test I’m having the same issue and I really should get it fixed the right way. Currently I just use two copies of the test file one in the editor and one in the scripts file which makes it work but is not right obviously. The problem seems to arise from the changes made to how the testing works. The issue itself is that in the ActionMasterTest.cs and the ScoreMasterTest.cs come up with an error of — Assets/Editor/Tests/ScoreMasterTest.cs(26,38): error CS0103: The name `ScoreMaster’ does not exist in the current context it seems to not recognize the scripts folder when trying to call the corresponding asset. ScoreMaster for ScoreMasterTest and ActionMaster for ActionMasterTest. Looking at the docs for Unity unless I’m reading it wrong it’s stating I can’t link them. If that’s true is making a separate copy the best route to go? If it’s not true and they can be linked how so? (If stated prior I missed it I apologize) Oh I should mention that if I move the ScoreMaster or ActionMaster in to the editor folder to fix the break it then breaks everything tied to those scripts instead.

Privacy & Terms