Skip to main content
added 179 characters in body
Source Link
jzx
  • 3.8k
  • 2
  • 26
  • 38

Of course you can check the syntax automatically using an IDE like Visual Studio. However, without some more work the only measure of correctness is "does it do what you expect?" If it doesn't, then you would debug to find out why.

Of course, you can take it a step further and apply Unit Testing. This is where you write code that sets up scenarios where you know there will be an expected result. For example, if you had a method like

int Add(int left, int right) { return left + right; }

you could write unit tests like

bool TestAdd() { return Add(2, 2) == 4; }

You then run all these tests in a separate mode and take note of which ones fail, or you can use an external project that links in your code to run all the methods. Most Unit testing APIs like NUnit provide decorations so their test engines can automatically extract, run, and gather results from your tests.

Check out "Unit Tests By The Book" part 1 and part 2 on the Unity Blog.

Of course you can check the syntax automatically using an IDE like Visual Studio. However, without some more work the only measure of correctness is "does it do what you expect?" If it doesn't, then you would debug to find out why.

Of course, you can take it a step further and apply Unit Testing. This is where you write code that sets up scenarios where you know there will be an expected result. For example, if you had a method like

int Add(int left, int right) { return left + right; }

you could write unit tests like

bool TestAdd() { return Add(2, 2) == 4; }

You then run all these tests in a separate mode and take note of which ones fail, or you can use an external project that links in your code to run all the methods.

Check out "Unit Tests By The Book" part 1 and part 2 on the Unity Blog.

Of course you can check the syntax automatically using an IDE like Visual Studio. However, without some more work the only measure of correctness is "does it do what you expect?" If it doesn't, then you would debug to find out why.

Of course, you can take it a step further and apply Unit Testing. This is where you write code that sets up scenarios where you know there will be an expected result. For example, if you had a method like

int Add(int left, int right) { return left + right; }

you could write unit tests like

bool TestAdd() { return Add(2, 2) == 4; }

You then run all these tests in a separate mode and take note of which ones fail, or you can use an external project that links in your code to run all the methods. Most Unit testing APIs like NUnit provide decorations so their test engines can automatically extract, run, and gather results from your tests.

Check out "Unit Tests By The Book" part 1 and part 2 on the Unity Blog.

Source Link
jzx
  • 3.8k
  • 2
  • 26
  • 38

Of course you can check the syntax automatically using an IDE like Visual Studio. However, without some more work the only measure of correctness is "does it do what you expect?" If it doesn't, then you would debug to find out why.

Of course, you can take it a step further and apply Unit Testing. This is where you write code that sets up scenarios where you know there will be an expected result. For example, if you had a method like

int Add(int left, int right) { return left + right; }

you could write unit tests like

bool TestAdd() { return Add(2, 2) == 4; }

You then run all these tests in a separate mode and take note of which ones fail, or you can use an external project that links in your code to run all the methods.

Check out "Unit Tests By The Book" part 1 and part 2 on the Unity Blog.