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

JUnit BeforeClass/AfterClass are run before every test in a class, not just once

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Affects Version/s: 3.0.8
    • Fix Version/s: 4.2.0
    • Component/s: TestMgr
    • Sprint:
      BlueJ 4.2.0

      Description

      From a BlueJ Support message it was reported that if you use @BeforeClass or @AfterClass annotations in a BlueJ unit test, it will run before and after every test in that class, not just once for the whole class.

      Example code: http://www.mkyong.com/unittest/junit-4-tutorial-1-basic-usage/ and expected behaviour, compared to our output below.

      @BeforeClass - oneTimeSetUp
      @Before - setUp
      @Test - testOneItemCollection
      @After - tearDown
      @AfterClass - oneTimeTearDown
      @BeforeClass - oneTimeSetUp
      @Before - setUp
      @Test - testEmptyCollection
      @After - tearDown
      @AfterClass - oneTimeTearDown
      

      It should be fixed to ONLY run either before any tests are run, or after all tests have been run.

        Attachments

          Activity

            People

            • Assignee:
              hitech Hamza Hamza
              Reporter:
              plcs plcs
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: