Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit Test

Moves a ship around Earth seas. Earth is represented as a grid.

Meet the following requirements:

  • Given the initial starting point (x, y) of a ship and the direction (n, s, e, w) it is facing.

  • Implement commands that move the ship forward and backward (f, b).

  • Implement commands that turn the ship left and right (l, r).

  • The ship can receive a string with commands ("lrfb" is equivalent to left, right, forward, backwards).

  • Earth, as any other planet is a sphere. Implement wrapping from one edge of the grid to another.

  • Not the whole planet consists of seas. Roughly 30% is surface are islands and continents. Implement surface detection before each move to a new position.

This is a simple and complete program. It will show you how to write a good unit test.

Requirements:

  • JDK 21.
  • No system Gradle installation is required. The checked-in Gradle Wrapper downloads and uses the project's Gradle version.

How to run it:

  • Run tests and generate a test report (./build/reports/tests/test/index.html).
$ ./gradlew clean test

or

  • Run tests and generate both test and coverage reports (./build/reports/jacoco/test/html/index.html).
$ ./gradlew clean test jacocoTestReport

Logging:

  • Application code can log through the SLF4J API.
  • Log4j2 provides a synchronous console logger at runtime. Project logs default to INFO; other libraries default to WARN.
  • Override the project log level when needed: -Dtdd.ship.log.level=DEBUG.
private static final Logger LOGGER = LoggerFactory.getLogger(Ship.class);

LOGGER.info("Executed ship command");

About

Unit Test in java

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages