#Unit Test
1 messages · Page 1 of 1 (latest)
Anyone can help with with creating one? I am completely lost...
Basically trying to create a test which shows that my AI agent is or can patrol from point a to b
AI Move | Test your C# code online with .NET Fiddle code editor.
This is a link to script i'm currently using
You could check out this video on how to do runtime unit tests
https://www.youtube.com/watch?v=PDYB32qAsLU
Sign up for the Level 2 Game Dev Newsletter: http://eepurl.com/gGb8eP
In this video I'll show you how to write more effective Unit Tests in Unity. More importantly, I'll demonstrate how valuable Unit Tests can be for Unity projects of any size and Unity developers of any skill level.
#Unity3D #UnityTutorial #GameDevelopment
📦 Download the co...
Yeah i've seen it multiple times, but I don't understand how it will work for my code
I understand how his works and the logic
But idk how to apply it to mine
My logic is something like
Create patrol points (game object) a and b
see if the ai is at patrol A,
see if it moves to vector 3 location of point b.
test success
that is how i would do it
you just need to create and position your agent , set its goal.
wait the time it should take for it to reach the goal, check with assert that it reached the target position.
public class PlayModeTests
{
[UnityTest]
public IEnumerator PlayModeTestsWithEnumeratorPasses()
{
var gameObject = new GameObject();
var patrolPointA = new GameObject();
var patrolPointB = new GameObject();
var enemy = gameObject.AddComponent<enemy>();
yield return new WaitForSeconds(1);
Assert.AreEqual(new Vector3(patrolPointB));
}
}
I'm so confused lmfao
Does this kind of make sense?
I mean there are errors but I think it kind of is something along the lines of what i'm meant to do
Appart from what you are doing in Assert.AreEqual
you are not positioning the enenmy
you dont set the position of the controll points
and 1 second might be a bit short to reach the target
For the assert i would do a check if the enemy is in a cremten range the to target point
public class PlayModeTests
{
public Vector3 patrolPointA;
public Vector3 patrolPointB;
[UnityTest]
public IEnumerator PlayModeTestsWithEnumeratorPasses()
{
patrolPointA = new Vector3(0.0f, 0.0f, 0.0f);
patrolPointB = new Vector3(0.0f, 0.0f, 5.0f);
GameObject enemyAI = new GameObject();
enemyAI.transform.position = new Vector3(0.0f, 0.0f, 0.0f);
yield return new WaitForSeconds(5);
Assert.AreEqual(new Vector3(0.0f, 0.0f, 5.0f), enemyAI.transform.position);
}
}
@minor hatch
This shows as successful for some reason
but I feel like it's wrong
ok nvm it fails
Now I just need to get the AI to travel to that location through the test