Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
0
05_FDD_Assignement
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alma Berisha
05_FDD_Assignement
Commits
b2cfc124
Commit
b2cfc124
authored
2 months ago
by
Alma Berisha
Browse files
Options
Downloads
Patches
Plain Diff
ObstacleDetection implemented and tested
parent
92b930b1
No related branches found
No related tags found
1 merge request
!1
Develop
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
02_UC_ObstacleDetection.txt
+55
-0
55 additions, 0 deletions
02_UC_ObstacleDetection.txt
backuprover2.py
+44
-0
44 additions, 0 deletions
backuprover2.py
test_rover2.py
+20
-0
20 additions, 0 deletions
test_rover2.py
with
119 additions
and
0 deletions
02_UC_ObstacleDetection.txt
0 → 100644
+
55
−
0
View file @
b2cfc124
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"
}
}
]
This diff is collapsed.
Click to expand it.
backuprover2.py
0 → 100644
+
44
−
0
View file @
b2cfc124
# 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
]
This diff is collapsed.
Click to expand it.
test_rover2.py
0 → 100644
+
20
−
0
View file @
b2cfc124
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment