diff --git a/03_UC_MissionControlMap.txt b/03_UC_MissionControlMap.txt new file mode 100644 index 0000000000000000000000000000000000000000..c6c55f037cffff211bf21fc7b695267e762d1931 --- /dev/null +++ b/03_UC_MissionControlMap.txt @@ -0,0 +1,73 @@ +You are a tester tasked with creating comprehensive test cases for a given usecase description. + +## Usecase description + +{ + "name": "MissionControl Map Tracking", + "scenario": "The rover tracks all visited positions during execution so that MissionControl can recreate the path.", + "actors": "MissionControl", + "preconditions": "The rover is landed on the plateau at position (0,0)", + "steps": [ + "MissionControl sends a movement command to the rover", + "Rover executes each movement command (F, B, L, R)", + "Rover records each visited position in order", + "MissionControl calls a method to retrieve the full path history", + "The system returns the sequence of all visited coordinates" + ] +} + +## Testcase + +[ + { + "name": "Path Tracking with No Obstacles", + "description": "Verify that the rover records all visited positions when no obstacles are present", + "input": { + "command": "FFRFF" + }, + "expected": { + "executedCommands": "FFRFF", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [1, 2], + [2, 2], + [3, 2] + ] + } + }, + { + "name": "Path Tracking Stops at Obstacle", + "description": "Verify that the rover records the path until just before an obstacle is detected", + "input": { + "command": "FFRFF" + }, + "expected": { + "executedCommands": "FFR", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [1, 2] + ] + } + }, + { + "name": "Path Tracking with Backward Movement", + "description": "Verify that backward movements are correctly added to the path", + "input": { + "command": "FFLBB" + }, + "expected": { + "executedCommands": "FFLBB", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [-1, 2], + [-2, 2] + ] + } + } +] diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2c11b785955d3e27664fec894a9b871bdd3057be --- /dev/null +++ b/README.md @@ -0,0 +1,189 @@ +RoverMovement +You are a tester tasked with creating comprehensive test cases for a given usecase description. + +Usecase descpription + +{ + "name": "Driving the Rover on Mars", + "scenario": "MissionControl sends drive commands to move the rover across the plateau.", + "actors": "MissionControl", + "preconditions": "Rover is landed on the plateau at position (0,0)", + "steps": [ + "MissionControl sends command string (e.g. 'FFRLF') to the rover", + "Rover interprets each character and updates position/heading accordingly", + "Before each move, Rover checks for obstacles or plateau boundaries", + "If an obstacle or edge is detected, Rover stops and ignores remaining commands", + "Rover returns the string of successfully executed commands" + ] +} + +Testcase +[ + { + "name": "Rover Moves Successfully with No Obstacles", + "description": "Verify that the rover moves as expected with valid input and no obstacles", + "input": { + "command": "FFRFF" + }, + "expected": { + "outcome": "Rover moved successfully", + "executedCommands": "FFRFF" + } + }, + { + "name": "Rover Stops at Obstacle", + "description": "Verify that the rover stops when an obstacle is detected and remaining commands are ignored", + "input": { + "command": "FFRFF" + }, + "expected": { + "outcome": "Rover stopped due to obstacle", + "executedCommands": "FFR" + } + }, + { + "name": "Invalid Command Input", + "description": "Verify that the rover handles invalid commands gracefully", + "input": { + "command": "FXZ" + }, + "expected": { + "outcome": "Invalid command encountered", + "executedCommands": "F" + } + } +] + +ObstacleDetection + +You are a tester tasked with creating comprehensive test cases for a given usecase description. + +Usecase description + +{ + "name": "Rover Obstacle Detection", + "scenario": "The rover must stop when it detects an obstacle in its path.", + "actors": "MissionControl", + "preconditions": "Rover is landed on the plateau at position (0,0)", + "steps": [ + "MissionControl sends a movement command to the rover", + "Rover checks each step for obstacles using its obstacle detection system (ODS)", + "If an obstacle is detected, the rover stops before moving into it", + "Remaining commands in the sequence are ignored", + "Rover returns only the successfully executed commands" + ] +} + +Testcase + +[ + { + "name": "Rover Stops at First Obstacle", + "description": "Verify that the rover stops immediately when the first obstacle is detected", + "input": { + "command": "FFRFF" + }, + "expected": { + "outcome": "Obstacle detected; rover stopped", + "executedCommands": "FF" + } + }, + { + "name": "Rover Avoids Obstacle and Continues", + "description": "Verify that rover only moves until just before the obstacle", + "input": { + "command": "FRFRF" + }, + "expected": { + "outcome": "Obstacle detected mid-sequence", + "executedCommands": "FRF" + } + }, + { + "name": "Rover Encounters No Obstacles", + "description": "Verify that the rover executes all commands when no obstacles are present", + "input": { + "command": "FFLFF" + }, + "expected": { + "outcome": "Rover moved successfully", + "executedCommands": "FFLFF" + } + } +] + +ControlMap + +You are a tester tasked with creating comprehensive test cases for a given usecase description. + +Use description + +{ + "name": "MissionControl Map Tracking", + "scenario": "The rover tracks all visited positions during execution so that MissionControl can recreate the path.", + "actors": "MissionControl", + "preconditions": "The rover is landed on the plateau at position (0,0)", + "steps": [ + "MissionControl sends a movement command to the rover", + "Rover executes each movement command (F, B, L, R)", + "Rover records each visited position in order", + "MissionControl calls a method to retrieve the full path history", + "The system returns the sequence of all visited coordinates" + ] +} + +Testcase + +[ + { + "name": "Path Tracking with No Obstacles", + "description": "Verify that the rover records all visited positions when no obstacles are present", + "input": { + "command": "FFRFF" + }, + "expected": { + "executedCommands": "FFRFF", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [1, 2], + [2, 2], + [3, 2] + ] + } + }, + { + "name": "Path Tracking Stops at Obstacle", + "description": "Verify that the rover records the path until just before an obstacle is detected", + "input": { + "command": "FFRFF" + }, + "expected": { + "executedCommands": "FFR", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [1, 2] + ] + } + }, + { + "name": "Path Tracking with Backward Movement", + "description": "Verify that backward movements are correctly added to the path", + "input": { + "command": "FFLBB" + }, + "expected": { + "executedCommands": "FFLBB", + "path": [ + [0, 0], + [0, 1], + [0, 2], + [-1, 2], + [-2, 2] + ] + } + } +] diff --git a/my_rover.py b/my_rover.py new file mode 100644 index 0000000000000000000000000000000000000000..c0387cdbcdf14ebed239f1d790e23ce7200622af --- /dev/null +++ b/my_rover.py @@ -0,0 +1,49 @@ +# adds missionconrtoll to rover2.py +DIRECTIONS = ['N', 'E', 'S', 'W'] +MOVES = { + 'N': (0, 1), + 'E': (1, 0), + 'S': (0, -1), + 'W': (-1, 0) +} + +class Rover: + def __init__(self, obstacles=None): + self.x = 0 + self.y = 0 + self.heading = 0 + self.obstacles = obstacles if obstacles else set() + self.path = [(0, 0)] + + def drive(self, command_string): + executed = "" + for cmd in command_string: + if cmd in ['F', 'B']: + dx, dy = MOVES[DIRECTIONS[self.heading]] + if cmd == 'B': + dx, dy = -dx, -dy + next_x = self.x + dx + next_y = self.y + dy + if (next_x, next_y) in self.obstacles: + break + self.x = next_x + self.y = next_y + self.path.append((self.x, self.y)) + elif cmd == 'L': + self.heading = (self.heading - 1) % 4 + elif cmd == 'R': + self.heading = (self.heading + 1) % 4 + else: + break + executed += cmd + return executed + + def get_position(self): + return (self.x, self.y) + + def get_heading(self): + return DIRECTIONS[self.heading] + + def get_path(self): + return self.path + diff --git a/test_rover3.py b/test_rover3.py new file mode 100644 index 0000000000000000000000000000000000000000..146f6b77a6552ab3793df082ba0f6a98fc8064f2 --- /dev/null +++ b/test_rover3.py @@ -0,0 +1,18 @@ +from my_rover import Rover + +def test_path_tracking_no_obstacles(): + rover = Rover() + rover.drive("FFRFF") + assert rover.get_path() == [(0,0), (0,1), (0,2), (1,2), (2,2)] + assert rover.get_position() == (2,2) + +def test_path_tracking_stops_at_obstacle(): + rover = Rover(obstacles={(1, 2)}) + rover.drive("FFRFF") + assert rover.get_path() == [(0,0), (0,1), (0,2)] + assert rover.get_position() == (0,2) + +def test_backward_path_tracking(): + rover = Rover() + rover.drive("FFLFFBB") + assert rover.get_path() == [(0,0), (0,1), (0,2), (-1,2), (-2,2), (-1,2), (0,2)]