This Java-based Robot Simulator lets you control a robot in a 2D room using simple text commands. It supports movement, pen up/down drawing, grid printing, and boundary validation. Tests and coverage are integrated using JUnit and JaCoCo.
Moving-Robot-main/
βββ src/
β βββ main/java/sourceCode/
β β βββ Robot.java # Core logic for robot movement
β βββ test/java/test/
β βββ RobotTest.java # JUnit tests for robot logic
β βββ QATest.java # Additional tests for edge cases
βββ target/ # Compiled classes and reports
βββ pom.xml # Maven configuration
βββ README.md
I nβ Initialize the grid (e.g.,I 5for 5x5)M nβ Move the robot forwardnstepsL/Rβ Turn left or rightU/Dβ Pen up or pen downPβ Print the room grid and robot's pathCβ Print robot's current status (position, direction, pen)
Includes boundary checks, invalid command handling, and a clear room printout.
- Java 8+
- Maven 3+
git clone https://github.com/mohammedsohail-dev/QAtesting.git
cd Moving-Robot-main
mvn clean compile
π§ͺ Testing & Coverage β Run Unit Tests
mvn test
Uses JUnit 4 (for RobotTest.java) and JUnit 5 (QATest.java).
JUnit Vintage engine bridges the two.
π Generate JaCoCo Coverage Report
mvn clean test
mvn package
Then open the report:
target/site/jacoco/index.html
View detailed method and line-level coverage. π‘ Sample Commands
I 5
D
M 3
R
M 2
C
P
Expected output:
Robot moves 3 steps forward with pen down.
Turns right and moves 2 steps.
Room grid printed with * marking the path.