#Unit Test

1 messages · Page 1 of 1 (latest)

swift wraith
#

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

#

This is a link to script i'm currently using

minor hatch
#

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...

â–¶ Play video
swift wraith
#

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

minor hatch
swift wraith
#
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));
    }
}
swift wraith
#

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

minor hatch
swift wraith
#

hm

#

I need to create vector positionings for both patrol points

swift wraith
#
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

swift wraith
#

Hm

#

The test I wrote doesn't necessarily 'test' it's basically hard code?