0

We were given a jar file to do blackbox testing on the methods. I know one test is supposed to give us a runtime exception but I'm getting a null pointer exception. My question is do I have this setup correctly and do you guys know where I'm going wrong?

Package explorer is like this

Single test case

Imported JAR file into build path correctly?

Test case that is giving the wrong error

UML Diagram

Naman
  • 27,789
  • 26
  • 218
  • 353
Krio
  • 19
  • 6
  • Links in the question do not help much(at least unless the actual question is clear otherwise). Please edit the question to include the information. – Naman Oct 21 '19 at 03:44

1 Answers1

0

I've never used Eclipse, but from your output it looks like everything is setup fine.

I'm not surprised by the NullPointerException either; you called addCourse() and passed null instead of a Course.

This is clearly homework. I don't know what your directions are, but if you don't expect that method to throw NPE, you probably shouldn't be putting nulls in there.

Since the exception you're looking for is CourseOverlapException, you probably ought to try adding two SingleLectureCourses that have overlapping time ranges.

Greg Chabala
  • 1,125
  • 2
  • 23
  • 35
  • It is homework I just wanted to see why the freebie that he threw us wasn't working the way it should have, he basically said "Null values result in an uncaught runtime exception". I was also figuring out if I had everything setup properly because we didn't really learn how to use jars for blackbox testing so I sort of winged it and I guess I got it to be the way it should. – Krio Oct 21 '19 at 05:08
  • A NPE is a kind of runtime exception. Your test should show that you expect it will be thrown, either by adding it to the `@Test` annotation or by catching it in the test and asserting about it. – Greg Chabala Oct 21 '19 at 14:20