Test expected an Exception, Exception was thrown (it shows in the output) but test failed anyway

后端 未结 3 1788
一整个雨季
一整个雨季 2021-01-27 07:17

Hi so there\'s a test for a constructor for a vehicle. The test initializes a vehicle with a driver without a driving license and it should throw an Exception. code constructor

3条回答
  •  暖寄归人
    2021-01-27 07:46

    Here:

        } catch (MensException e) {
            System.out.println(e.getMessage());
        } 
    

    You catch the exception so it is not thrown to the test class.

    Change to to:

    } catch (MensException e) {
        System.out.println(e.getMessage());
        throw e
    } 
    

提交回复
热议问题