C # programmer's Unity 3D notes (9): Unity 3D test analysis,
Classes on components in Unity cannot be new and must be obtained through components. The new class is null.
If (amainfo. nameHash = Animator. StringToHash (Base Layer. idle ))
{
M_animator.SetBool (Run, true );
}
When the Code cannot be executed, click Bake in the navigation panel, as shown in figure
You must add a collision component to the collision body. Otherwise, the Physics. Raycast function cannot detect the collision.
The time when destory is deleted. Otherwise, the multi-thread generated will result in inaccurate counting!
Unity3D comes with a Test tool. You only need to download the tool from Asset Store and import it. After the tool is imported, the Unity Test Tools item (such as) appears in the menu. The plug-in is imported, you can perform a unit test.
The unit test of Unity3D is almost the same as that of VS2010. If you have been in contact with unit test of VS, the unit test of Unity3D will be much simpler.
1. Create a New 'editor' folder and create a unit test class in the folder, as shown in figure
2. Add the required test method to the test class file, which is basically the same as unit test in VS, as shown in:
3. Complete the creation of the Test class. Click Unit Test Runner in the Unity Test Tools menu to perform the Unit Test, for example:
4. click the unit test menu to go to the test page. Click the start test button to view the new test class and the method to be tested. When the green check mark is displayed, the test passes, otherwise, the test fails, for example:
The above are the basic steps for running the Unity3D unit test. If you are familiar with the VS development platform, you will find that the unit test is almost the same as that of.
Integration Test Integration
Unit tests can only test the logic of individual functions and cannot simulate real game operation scenarios. Therefore, integration tests are required to simulate General game scenarios. Unity3D integration testing calls the running functions of Unity to test the use cases one by one. It is equivalent to the actual game running environment.
Integration Testing includes dynamic integration testing and general integration testing.
1. General integration test. If you want to test a GameObject, you need to add the script component 2.
Menu. After adding the component, you can test and run the component.
You can see the result. For example:
Figure 1
Figure 2
Each integration test must be judged by the asserted component. This normal test is only used for some simple tests, such as coordinate moving range and visibility.
Dynamic Integration Test
Create a New Test, create a GameObject under it, and create a TestScript to bind it to the GameObject.
In this scenario, the dynamic test script is automatically mounted to the test panel. For example:
Create several test classes in the. cs file. You can test different modules in different test scenarios. It also supports many NGUI plug-ins. The button RESPONSE event is forcibly called Using Reflection.
For more information, visit the Unity3D training expert www.gopedu.com.
Disclaimer: This document is from the "Dog Learning Network" community. It is an Unity3D learning article published by netizens. If any content infringes on your rights and interests, please contact the official website, it will be processed in real time.
For more information, visit the Unity3D training expert www.gopedu.com.