Testing is handled using JUnit, a powerful framework that allows you to check different aspects of your code.
Unit tests can be run with the following commands.
cd lab1-git-race
gradle testAll verification tasks, including unit tests, can be run with the following commands. Gradle offers a flag, -i, that can be used to show more information while running the checks.
cd lab1-git-race
gradle checkThere's 3 tests, stored at src/test/kotlin, that have been made for this Kotlin Webpage
The file src/test/kotlin/IntegrationTest.kt contains two tests that checks the main behaivour of the HTML page itself:
-
testHome()checks if making a request athttp://localhost:$port(With$portin this case being 0 for the shake of the test), yields both:-
A
OKHTTP Status Code. -
A HTML body with
<title>hello.If this happens, we can assume the webpage's HTML is the one intended.
-
-
testCss()checks if the CSS of the webpage has basic functionality. For this, it requesthttp://localhost:$port/webjars/bootstrap/5.1.0/css/bootstrap.min.cssfrom the Web Server, and checks if it has a response with:- A
OKHTML Status. - A body with
"body". - A file with a header equal to that of
"text/css".
- A
This ensures the webpage has a valid CSS file.