Skip to content

Commit

Permalink
Merge pull request #333 from tier4/feature/improved-tests-description
Browse files Browse the repository at this point in the history
Improved tests description
  • Loading branch information
mackierx111 authored Jul 18, 2024
2 parents d41ae4e + 103ee28 commit 17d7539
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 22 deletions.
46 changes: 39 additions & 7 deletions Assets/Tests/EditMode/Lanelet/LaneletTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,13 @@ private void DestroyLanelet()
// --- TEST ROUTINES --- //

/// <summary>
/// Test to validate if the correct number of objects is imported from the .osm file to the Unity scene.
/// Test Outline:
/// - Validate the import process of a .osm file to the Unity scene.
/// - Test if correct number of objects are imported from the .osm file.
/// Test Target:
/// - Check if the LaneletLoader script correctly imports .osm data into the Unity scene.
/// Expected Result:
/// - The number of objects imported into the Unity scene matches the expected number from the .osm file.
/// </summary>
[UnityTest]
public IEnumerator LaneletImporter_ObjectCount()
Expand All @@ -120,7 +126,14 @@ public IEnumerator LaneletImporter_ObjectCount()
}

/// <summary>
/// Test to validate if each imported TrafficLane has correctly imported the waypoint array.
/// Test Outline:
/// - Validate the import process of a .osm file to the Unity scene.
/// - Test if each TrafficLane has correctly imported its associated waypoint array.
/// Test Target:
/// - Check if the LaneletLoader script correctly imports .osm data into the Unity scene.
/// - Check if each imported TrafficLane contains the valid waypoint array.
/// Expected Result:
/// - Each imported TrafficLane has an imported waypoint array that is not empty and has at least to 2 elements.
/// </summary>
[UnityTest]
public IEnumerator LaneletImporter_TrafficLane_WaypointLenght()
Expand All @@ -146,7 +159,14 @@ public IEnumerator LaneletImporter_TrafficLane_WaypointLenght()
}

/// <summary>
/// Test to validate if each imported TrafficLane has been placed in the correct position in the Unity scene.
/// Test Outline:
/// - Validate the import process of a .osm file to the Unity scene.
/// - Test the placement of imported TrafficLane objects in the Unity scene.
/// Test Target:
/// - Check if the LaneletLoader script correctly imports .osm data into the Unity scene.
/// - Check if each imported TrafficLane is positioned correctly in the Unity scene.
/// Expected Result:
/// - Whether each TrafficLane object is placed at the position equal to the first point in the waypoints array.
/// </summary>
[UnityTest]
public IEnumerator LaneletImporter_TrafficLane_LanePosition()
Expand Down Expand Up @@ -174,8 +194,14 @@ public IEnumerator LaneletImporter_TrafficLane_LanePosition()
}

/// <summary>
/// Test to validate if TrafficLanes have been imported correctly and if there are no gaps between
/// one traffic lane and the next traffic lane.
/// Test Outline:
/// - Validate the import process of a .osm file to the Unity scene.
/// - Check for continuity between consecutive TrafficLanes.
/// Test Target:
/// - Check if the LaneletLoader script correctly imports .osm data into the Unity scene.
/// - Verify there are no gaps between one TrafficLane and the next.
/// Expected Result:
/// - The value of the last waypoint of one TrafficLane matches the value of the first waypoint of the next TrafficLane.
/// </summary>
[UnityTest]
public IEnumerator LaneletImporter_NextLanePosition()
Expand Down Expand Up @@ -209,8 +235,14 @@ public IEnumerator LaneletImporter_NextLanePosition()
}

/// <summary>
/// Test to validate if TrafficLanes have been imported correctly and if there are no gaps between
/// one traffic lane and the previous traffic lane.
/// Test Outline:
/// - Validate the import process of a .osm file to the Unity scene.
/// - Ensure there are no gaps between consecutive TrafficLanes.
/// Test Target:
/// - Check if the LaneletLoader script correctly imports .osm data into the Unity scene.
/// - Verify there are no gaps between one TrafficLane and the previous one.
/// Expected Result:
/// - The value of the first waypoint of one TrafficLane matches the value of the last waypoint of the previous TrafficLane.
/// </summary>
[UnityTest]
public IEnumerator LaneletImporter_PreviousLanePosition()
Expand Down
68 changes: 53 additions & 15 deletions Assets/Tests/PlayMode/Traffic/TrafficTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ public IEnumerator TearDown()
static int[] numberOfNPCs = new int[] { 1, 2, 3, 4 };

/// <summary>
/// A test to validate if the traffic manager spawns the correct number of NPCs, and if the expected prefab is spawned.
/// Test Outline:
/// - A given number of NPCs is going to be spawned into the scene.
/// Test Target:
/// - Check if the TrafficManager script spawns the correct number of NPCs.
/// - Verify that the NPCs spawned are of the expected type.
/// Expected Result:
/// - The Traffic Manager spawns the exact number of NPCs as specified.
/// - Spawned NPC matches the expected prefab type.
/// </summary>
[UnityTest]
public IEnumerator RandomTrafficSpawn([ValueSource("numberOfNPCs")] int numberOfNPCs)
Expand Down Expand Up @@ -130,7 +137,12 @@ public IEnumerator RandomTrafficSpawn([ValueSource("numberOfNPCs")] int numberOf
};

/// <summary>
/// A test to validate if the traffic manager spawns the correct type of NPCs for a given seed number.
/// Test Outline:
/// - The NPCs vehicle are going to be spawned for the given seed number.
/// Test Target:
/// - Check if the TrafficManager script spawns NPCs that correspond to the given seed number.
/// Expected Result:
/// - Each spawned NPC matches the type expected based on the seed and the 'expectedSpawns' list.
/// </summary>
[UnityTest]
public IEnumerator SeedSpawn([ValueSource("seedNumbers")] int seed)
Expand Down Expand Up @@ -166,7 +178,12 @@ public IEnumerator SeedSpawn([ValueSource("seedNumbers")] int seed)
}

/// <summary>
/// A test to validate if the NPCs are correctly despawned.
/// Test Outline:
/// - A single NPC is added to the scene and despawns after 10 seconds.
/// Test Target:
/// - Verify that the TrafficManager script despawns NPCs correctly.
/// Expected Result:
/// - There should be no NPCs in the scene after 10 seconds.
/// </summary>
[UnityTest]
public IEnumerator Despawn()
Expand Down Expand Up @@ -197,9 +214,16 @@ public IEnumerator Despawn()
}

/// <summary>
/// A test to validate the correctness of the traffic simulator behavior. In this test,
/// a single NPC vehicle enters the intersection when the GREEN light turns on.
/// The expected behavior assumes that the NPC vehicle moves through the intersection without stopping.
/// Test Outline:
/// - A single NPC enters the intersection when the GREEN light is on.
/// - The synchronization between the traffic light timing and the NPC approaching the intersection is set
/// to ensure that the NPC encounter the GREEN light.
/// Test Target:
/// - Test if the functionality of the TrafficManager, which decides if NPCs can pass through the intersection
/// with the traffic light status taken into account, works correctly.
/// Expected Result:
/// - The NPC vehicle passes through the intersection smoothly without stopping.
/// - During each second of movement, the NPC maintains a speed greater than 0f.
/// </summary>
[UnityTest]
public IEnumerator TrafficManager_MoveStraight_GreenLight()
Expand Down Expand Up @@ -242,9 +266,16 @@ public IEnumerator TrafficManager_MoveStraight_GreenLight()
}

/// <summary>
/// A test to validate the correctness of the traffic simulator behavior. In this test,
/// a single NPC vehicle enters the intersection when the RED light is on.
/// The expected behavior assumes that the NPC vehicle stops at the intersection and waits for the green light.
/// Test Outline:
/// - A single NPC enters the intersection when the RED light is on.
/// - The synchronization between the traffic light timing and the NPC approaching the intersection is set
/// to ensure that the NPC encounter the RED light.
/// Test Target:
/// - Test if the functionality of the TrafficManager, which decides if NPCs can pass through the intersection
/// with the traffic light status taken into account, works correctly.
/// Expected Result:
/// - The NPC vehicle comes to a complete stop at the intersection upon encountering the RED light.
/// - The NPC remains stationary until the traffic light turns GREEN, indicating it can proceed.
/// </summary>
[UnityTest]
public IEnumerator TrafficManager_MoveStraight_RedLight()
Expand Down Expand Up @@ -293,12 +324,19 @@ public IEnumerator TrafficManager_MoveStraight_RedLight()
}

/// <summary>
/// A test to validate the correctness of traffic simulator behavior. In this test, two NPC vehicles
/// enter the intersection when the GREEN light is on. These NPCs enter the intersection from opposite sides,
/// with one vehicle about to turn right and the other moving straight through the intersection.
/// Expected behavior:
/// - the first vehicle (turning right) must yield to the second vehicle.
/// - the second vehicle (moving straight) should proceed through the intersection without stopping.
/// Test Outline:
/// - Two NPC vehicles enter the intersection from opposite sides while both have a GREEN light.
/// - One NPC is preparing to turn right, and the other is moving straight through the intersection.
/// - The traffic light timing and NPCs synchronization ensure that both encounter the GREEN light,
/// with the turning vehicle yielding to the straight-moving vehicle.
/// Test Target:
/// - Test if the functionality of the TrafficManager, which decides if NPCs can proceed through
/// the intersection with the traffic light status taken into account, works correctly.
/// - Test if the functionality of the TrafficManager, which decides the yield rules at
/// the intersection, works correctly.
/// Expected Result:
/// - The NPC turning right yields to the NPC moving straight through the intersection.
/// - The NPC moving straight through the intersection proceeds without stopping.
/// </summary>
[UnityTest]
public IEnumerator TrafficManager_Oposite_GreeLight()
Expand Down

0 comments on commit 17d7539

Please sign in to comment.