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?
Answer by MaxGuernseyIII · Aug 30, 2017 at 08:09 PM
Use the discipline of test-driven development.
Visual Studio 2017 and Unity integrate very well and the Community edition of Visual Studio is free.
Install Visual Studio 2017 (or better).
Make sure Visual Studio is your editor.
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:
Add a new project to your test solution.
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.
Write a test that expresses how a class should work.
Stub out enough of the class to see the test fail.
Make the test pass.
Refactor for quality.
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.
Reference Solution - 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).
I think this goes without saying but you don't need to repeat the setup steps, just the TDD part (write a test, see it fail, make it pass, refactor).
When I open my file with visual studio 2017, it says that is an incompatible file.
There are a lot of reasons that could be:
You might have opened the wrong kind of thing from Visual Studio.
You may have not installed the Unity workload in Visual Studio.
The Visual Studio-unity integration sometimes wants you to open Visual Studio directly from Unity.
I'm sure there are others.
In any event, assu$$anonymous$$g you have the Unity tools installed in VS, you can do things by hand the first time:
Create a new project using the class library (.Net framework) template.
Change the target framework to one of the Unity platforms (if you don't have them, you haven't installed the Unity workload).
Change the output path of the production assembly to point to your Assets/bin folder.
Create a test project using an appropriate template.
Add a reference from your test project to your production project.
Start doing TDD.
O$$anonymous$$, I don't have the Unity class library installed. Do I have to uninstall VS 2017 and re-install it? Or I can do it manually?
You can add or remove the components with the Visual Studio Installer. That should be available from somewhere in your start menu. I'm out to eat with my wife and children but I'll send you a very small reference solution when I get home, if you like. You shouldn't use it to do your work but you can use it to validate your Visual Studio install and to help guide building your own solution.
Thank you very much for your help, Now my VS is updating. I guess now I can find the Unity extension.
Your answer
Follow this Question
Related Questions
Best way to learn how to utilize the Unity API? 2 Answers
Accessing Variables inside classes inside other classes? 1 Answer
Raycast shotgun help! 2 Answers
What is wrong with my code? C# beginner 1 Answer
why the Timer isn't working 0 Answers