SimpleTests fail

Hey everyone,
so I tried getting started with the tests of the new project and I tried running the simple tests that are already provided. What I understood by now, the second test should pass since create() in UriParserFactory and parse() both ouput null by now. But for me, and for some of my friends, all three tests fail while for others it works perfectly fine.
image
I did not change any code yet. I only added one test which shouldn’t affect the SimpleTests.
Thanks in advance!

3 Likes

These are only tests for some UrlParser implementation. As long as you did not write any, you will not be able to run your tests. As soon as you written an implementation, you can return it in the UrlParserFactory class as an implementation of the UrlParser interface.

If you did not implement anything yet, you will need to use the daily tests to find out:

  1. Whether your tests are even correct (as they are tested against a valid implementation during the daily tests)
  2. Your tests test enough to find issues in invalid implementations
You can still try to run them locally without an implementation to find any syntax errors!
3 Likes

Okay, I still don’t get why they then pass for others who also haven’t implemented any code yet, but thanks for your help!

Regarding testNegativeSimple:
As Nicolas said, this test assumes that the factory returns a parser. It then looks whether the parser returns null when parse is invoked:

		assertNull(UriParserFactory.create("").parse());

You can see this in the error message when running the test:

java.lang.NullPointerException
 at uri.tests.SimpleTests.testNegativeSimple(SimpleTests.java:49)

This exception means: Java tried to access something from a object which was null.
In our case, it tried:

null.parse()

But the test prog2.tests.pub.UriParserTests::testNull should be successful in an empty project.
It tests that the factory returns null when invoked with null as the argument.

2 Likes

Okay, I get it now. The test you named is successful for me, thank you for your help.

1 Like