From 92b930b15f6e6fc7289e6bab7418ef0945a34275 Mon Sep 17 00:00:00 2001
From: Almmaa <Alma.Berisha@student.reutlingen-university.de>
Date: Sun, 4 May 2025 15:13:01 +0200
Subject: [PATCH 1/3] basic movement implempented and tested

---
 01_UC_RoverMovement.txt | 54 +++++++++++++++++++++++++++++++++++++++++
 backuprover1.py         | 42 ++++++++++++++++++++++++++++++++
 test_rover1.py          | 19 +++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100644 01_UC_RoverMovement.txt
 create mode 100644 backuprover1.py
 create mode 100644 test_rover1.py

diff --git a/01_UC_RoverMovement.txt b/01_UC_RoverMovement.txt
new file mode 100644
index 0000000..0794a9b
--- /dev/null
+++ b/01_UC_RoverMovement.txt
@@ -0,0 +1,54 @@
+You are a tester tasked with creating comprehensive test cases for a given usecase description.
+
+## Usecase description
+
+{
+    "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"
+        }
+    }
+]
diff --git a/backuprover1.py b/backuprover1.py
new file mode 100644
index 0000000..66a26d1
--- /dev/null
+++ b/backuprover1.py
@@ -0,0 +1,42 @@
+# RoverMovement: (F, B, L, R)
+# ObstacleDetection : (ODS)
+
+DIRECTIONS = ['N', 'E', 'S', 'W']
+MOVES = {
+    'N': (0, 1),
+    'E': (1, 0),
+    'S': (0, -1),
+    'W': (-1, 0)
+}
+
+class Rover:
+    def __init__(self):
+        self.x = 0
+        self.y = 0
+        self.heading = 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
+                self.x += dx
+                self.y += dy
+            elif cmd == 'L':
+                self.heading = (self.heading - 1) % 4
+            elif cmd == 'R':
+                self.heading = (self.heading + 1) % 4
+            else:
+                break  # stop on invalid command
+            executed += cmd
+        return executed
+
+    def get_position(self):
+        return (self.x, self.y)
+
+    def get_heading(self):
+        return DIRECTIONS[self.heading]
+
+  
diff --git a/test_rover1.py b/test_rover1.py
new file mode 100644
index 0000000..bcab6d6
--- /dev/null
+++ b/test_rover1.py
@@ -0,0 +1,19 @@
+from backuprover1 import Rover
+
+# FEATURE 1: Basic Movement
+
+def test_basic_forward_movement():
+    rover = Rover()
+    result = rover.drive("FFRFF")
+    assert result == "FFRFF"
+    assert rover.get_position() == (2, 2)
+
+def test_invalid_command_stops_execution():
+    rover = Rover()
+    result = rover.drive("FXZ")
+    assert result == "F"
+
+def test_rotation_behavior():
+    rover = Rover()
+    rover.drive("LL")
+    assert rover.get_heading() == 'S'
-- 
GitLab


From b2cfc12476aeadb58fc509a41e155f55d2fb3ee0 Mon Sep 17 00:00:00 2001
From: Almmaa <Alma.Berisha@student.reutlingen-university.de>
Date: Sun, 4 May 2025 15:19:10 +0200
Subject: [PATCH 2/3] ObstacleDetection implemented and tested

---
 02_UC_ObstacleDetection.txt | 55 +++++++++++++++++++++++++++++++++++++
 backuprover2.py             | 44 +++++++++++++++++++++++++++++
 test_rover2.py              | 20 ++++++++++++++
 3 files changed, 119 insertions(+)
 create mode 100644 02_UC_ObstacleDetection.txt
 create mode 100644 backuprover2.py
 create mode 100644 test_rover2.py

diff --git a/02_UC_ObstacleDetection.txt b/02_UC_ObstacleDetection.txt
new file mode 100644
index 0000000..bf72cf0
--- /dev/null
+++ b/02_UC_ObstacleDetection.txt
@@ -0,0 +1,55 @@
+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"
+        }
+    }
+]
diff --git a/backuprover2.py b/backuprover2.py
new file mode 100644
index 0000000..6158277
--- /dev/null
+++ b/backuprover2.py
@@ -0,0 +1,44 @@
+# Adds obstacle detection to rover1.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()
+
+    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
+            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]
diff --git a/test_rover2.py b/test_rover2.py
new file mode 100644
index 0000000..c682e8e
--- /dev/null
+++ b/test_rover2.py
@@ -0,0 +1,20 @@
+from backuprover2 import Rover
+
+
+def test_stops_at_first_obstacle():
+    rover = Rover(obstacles={(0, 2)})
+    result = rover.drive("FFRFF")
+    assert result == "F"
+    assert rover.get_position() == (0, 1)
+
+def test_mid_sequence_obstacle():
+    rover = Rover(obstacles={(1, 1)})
+    result = rover.drive("FRFRF")
+    assert result == "FR"
+    assert rover.get_position() == (0, 1)
+
+def test_no_obstacles_full_execution():
+    rover = Rover()
+    result = rover.drive("FFLFF")
+    assert result == "FFLFF"
+    assert rover.get_position() == (-2, 2)
-- 
GitLab


From c99b131c1ac695998df5e1c663e0b6ae11ab7406 Mon Sep 17 00:00:00 2001
From: Almmaa <Alma.Berisha@student.reutlingen-university.de>
Date: Sun, 4 May 2025 15:38:16 +0200
Subject: [PATCH 3/3] Path tracking implementation

---
 03_UC_MissionControlMap.txt |  73 ++++++++++++++
 README.md                   | 189 ++++++++++++++++++++++++++++++++++++
 my_rover.py                 |  49 ++++++++++
 test_rover3.py              |  18 ++++
 4 files changed, 329 insertions(+)
 create mode 100644 03_UC_MissionControlMap.txt
 create mode 100644 README.md
 create mode 100644 my_rover.py
 create mode 100644 test_rover3.py

diff --git a/03_UC_MissionControlMap.txt b/03_UC_MissionControlMap.txt
new file mode 100644
index 0000000..c6c55f0
--- /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 0000000..2c11b78
--- /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 0000000..c0387cd
--- /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 0000000..146f6b7
--- /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)]
-- 
GitLab