diff --git a/01_UC_RoverMovement.txt b/01_UC_RoverMovement.txt new file mode 100644 index 0000000000000000000000000000000000000000..0794a9b41686d7120210cee2a50e614b45f09477 --- /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/02_UC_ObstacleDetection.txt b/02_UC_ObstacleDetection.txt new file mode 100644 index 0000000000000000000000000000000000000000..bf72cf00f99a6f736d5dbc99b06c8014c29d93f8 --- /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/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 index 3fbb7f0469aab21e785d72a651e1fed3db779205..2c11b785955d3e27664fec894a9b871bdd3057be 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,189 @@ -# 05_FDD_Assignement - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.reutlingen-university.de/Alma.Berisha/05_fdd_assignement.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.reutlingen-university.de/Alma.Berisha/05_fdd_assignement/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +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/backuprover1.py b/backuprover1.py new file mode 100644 index 0000000000000000000000000000000000000000..66a26d109220d400848acd6093b2ba3806b47cf1 --- /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/backuprover2.py b/backuprover2.py new file mode 100644 index 0000000000000000000000000000000000000000..6158277a9ceb630f94da7490bbf8e23516aeafc1 --- /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/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_rover1.py b/test_rover1.py new file mode 100644 index 0000000000000000000000000000000000000000..bcab6d64a282fc4b400504a3287dc3528148d75c --- /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' diff --git a/test_rover2.py b/test_rover2.py new file mode 100644 index 0000000000000000000000000000000000000000..c682e8ecb16a67cefabd213ed38e50bc7d254195 --- /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) 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)]