Understanding the provided simple test testIPv4AddressSimple()


I’m trying to understand the test “testIPv4AddressSimple()” provided in tests/SimpleTests.java. Here, we input a specific URI containing the host (here an IPv4address) So this test checks whether this host is indeed in the correct IPv4address format. But does this cover similar cases, such as or or …? In other words, to what extent do the provided values matter?

As you said, this test invokes the parser with “scheme://”.
It does not check the format but instead if the host is an IPv4Address.
A test is a concrete execution of the program.
Here, the parser is evaluated with the string above and this string only.
You need to write more tests to cover different behavior like leading zeros, more than one digit, … .

A test is nothing different from a normal function we run other than the fact that we write down if an error occurs (an assertion that fails) and tell the user: “Test failed” and the possibility to execute all of those functions conveniently.

1 Like