Uploaded image for project: 'BlueJ'
  1. BlueJ
  2. BLUEJ-118

Support for JUnit 4

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Low
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 3.0.5
    • Component/s: TestMgr

      Description

      We have recently switched to evaluating student submissions using statement level code coverage (as opposed to method level coverage) and JUnit 3 won't permit 100% coverage of a test case when an exception is thrown. i.e. in the JUnit 3 example below, the line "fail()" won't be executed and hence will reduce coverage percentage. But, in the JUnit 4 example, they'll get 100% coverage. In addition, JUnit 4 is just simpler in these cases.

      // JUnit 3
      public void testSomething()
      {
         SomeObject o = new SomeObject();
         try
         {
            o.someMethodThatThrows();
            fail();
         }
         catch (MyCustomExceptionClass ex)
         {
            // do nothing
         }
      }
      
      // JUnit 4
      @Test(expected = MyCustomeExceptionClass.class)
      public void testSomething()
      {
         SomeObject o = new SomeObject();
         o.someMethodThatThrows();
      }
      

        Attachments

          Activity

            People

            • Assignee:
              davmac Davin McCall
              Reporter:
              external External via trac
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: