How can you test your code with no assets yet.

Hello, guys, I’m going to start a project for college, and I want to test my codes before using them. How can I do this if I still haven’t got the assets from the artist?

Use the discipline of test-driven development.

Visual Studio 2017 and Unity integrate very well and the Community edition of Visual Studio is free.

  1. Install Visual Studio 2017 (or better).
  2. Make sure Visual Studio is your editor.
  3. Open your script from Unity, this will create a Visual Studio solution that is “aware” of your Unity stuff.

I like to put all my “scripts” into assemblies that compile to a Unity target platform and change their output to go to Assets\bin for my Unity project. Then I can do things like make other assemblies (such as test assemblies) depend on them.

Once you have your code organized, you can do just that:

  1. Add a new project to your test solution.
  2. Add a reference from your test project to the project containing your scripts.

Then you will be in a position to use test-driven development.

  1. Write a test that expresses how a class should work.
  2. Stub out enough of the class to see the test fail.
  3. Make the test pass.
  4. Refactor for quality.
  5. Repeat.

Don’t make the mistake of having the stuff you TDD be coupled to MonoBehaviour - make separate classes and then adapt them into Unity with thing, crispy implementations of MonoBehaviour.

Unity also has a test runner but, for coding, there is no development environment that matches Visual Studio.

Since you are ostensibly young, I’ll also add this advice: don’t believe anyone who says “TDD doesn’t apply to X”. It applies to everything, you just have to eliminate the barriers we create for ourselves first, sometimes.

If by “test” you mean “manually interact with”, like exploratory testing or something, then you can just create dummy assets. Your code shouldn’t be coupled to the assets you use anyway.

That said, if you are a coder, you’re way better off having precise definitions of the exact behaviors you want in your code base and a way to virtually instantly tell which ones are working the way you intend.

EDIT

Attaching a reference solution that can be used to validate a Visual Studio install.

[101041-writecodeinvisualstudio.zip|101041] - Download this, unzip it, and open up the .SLN file. If the projects build and you can run the tests, your Visual Studio install is ready. You can also poke through the settings to see how I set the target to a Unity platform and pointed the output to a build directory in a “unity project” (which I model with an empty folder because those are too large for this answers exchange).