Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Testing Exceptions Practice | Exceptions
course content

Зміст курсу

Java JUnit Library. Types of Testing

Testing Exceptions PracticeTesting Exceptions Practice

I hope you remember how you wrote exception handling in this chapter. It's time to practice writing tests for these assertions.

Task

Your task is to cover two methods from the ExceptionHandlingExercise class with tests using assertThrows() and assertDoesNotThrow() assertions in the unit test class that I have created for you.

Link to the Task: GitHub
  • Pay attention to the names of the unit tests; your task is to implement them so that they perform the function indicated in the name.
  • At the beginning of each test, you need to create an instance of the ExceptionHandlingExercise class. It will look like this:
    ExceptionHandlingExercise exercise = new ExceptionHandlingExercise();.
  • Next, you need to create a variable that will hold the value you want to test.
    For example: int underage = 17;.
  • Use the assertions you learned in the previous chapter.
  • You can optionally write additional tests for the functionality of these methods.
  • Все було зрозуміло?

    Секція 3. Розділ 7
    course content

    Зміст курсу

    Java JUnit Library. Types of Testing

    Testing Exceptions PracticeTesting Exceptions Practice

    I hope you remember how you wrote exception handling in this chapter. It's time to practice writing tests for these assertions.

    Task

    Your task is to cover two methods from the ExceptionHandlingExercise class with tests using assertThrows() and assertDoesNotThrow() assertions in the unit test class that I have created for you.

    Link to the Task: GitHub
  • Pay attention to the names of the unit tests; your task is to implement them so that they perform the function indicated in the name.
  • At the beginning of each test, you need to create an instance of the ExceptionHandlingExercise class. It will look like this:
    ExceptionHandlingExercise exercise = new ExceptionHandlingExercise();.
  • Next, you need to create a variable that will hold the value you want to test.
    For example: int underage = 17;.
  • Use the assertions you learned in the previous chapter.
  • You can optionally write additional tests for the functionality of these methods.
  • Все було зрозуміло?

    Секція 3. Розділ 7
    some-alt