Giter VIP home page Giter VIP logo

exceptionrunner's Introduction

Tasks to answer in your own README.md that you submit on Canvas:

  1. See logger.log, why is it different from the log to console?

The output to logger.log is different from that in the console because we specified in logger config file (logger.properties) that the log file handler should display all levels of log messages whereas the log console handler should only display info messages and above.

  1. Where does this line come from? FINER org.junit.jupiter.engine.execution.ConditionEvaluator logResult Evaluation of condition [org.junit.jupiter.engine.extension.DisabledCondition] resulted in: ConditionEvaluationResult [enabled = true, reason = '@Disabled is not present']

It comes from JUnit, specifically an internal function called "logResult" that gets called by Assertions.assertTrue.

  1. What does Assertions.assertThrows do?

Assertions.assertThrows executes the given Executable (in this case, a lambda). If the Executable throws an exception of the given type, then the assertion passes. Otherwise, the assertion fails, causing the entire test to fail.

  1. See TimerException and there are 3 questions
    1. What is serialVersionUID and why do we need it? (please read on Internet) -> serialVersionUID is "an identifier that is used to serialize/deserialize an object of a Serializable class" (Baeldung.com). We need it because an Exception is a Serializable, and we want to distinguish it from other kinds of Exceptions.
    2. Why do we need to override constructors? -> If we don't override the constructors, we won't be able to pass arguments into the exception's constructor. We typically want to be able to specify a description message for the exception and sometimes give another exception as the cause as well. Only the default constructor (no parameters) gets auto-generated by Java.
    3. Why we did not override other Exception methods? -> We didn't override other Exception methods because the Exception class is designed so that you typically don't need to do so--the default behavior is usually already great.
  2. The Timer.java has a static block static {}, what does it do? (determine when called by debugger)

The Timer.java static block gets called at the start of the program; it tries to open the log config file, load the config, and log an initial info message.

  1. What is README.md file format how is it related to bitbucket? (https://confluence.atlassian.com/bitbucketserver/markdown-syntax-guide-776639995.html)

It is called "Markdown", it lets devs easily format text for writing README files and PR descriptions and comments. Bitbucket is configured to display the formatted text automatically for maximum eye candy!

  1. Why is the test failing? what do we need to change in Timer? (fix that all tests pass and describe the issue)

The test is failing because the wait time given is negative, which causes the method to throw a TimerException, but the start time has not been initialized yet. This means that whenever we try to log the time difference (end - start), we get a NullPointerException because we're trying to do an operation on the null starting time value. The test fails because a NullPointerException gets thrown, but such an Exception was not expected by the JUnit test.

  1. What is the actual issue here, what is the sequence of Exceptions and handlers (debug)

Tester.timeMe throws a TimerException which causes the finally block in Timer.timeMe to execute. Then, a NullPointerException gets thrown during the subtraction and gets caught by the JUnit assertThrows method. Finally, an AssertionFailedError gets thrown which is what actually causes the test to fail.

  1. Make a printScreen of your eclipse JUnit5 plugin run (JUnit window at the bottom panel)

See ./junit.png

  1. Make a printScreen of your eclipse Maven test run, with console

See ./maven.png

  1. What category of Exceptions is TimerException and what is NullPointerException

TimerException is a checked exception and NullPointerException is an unchecked exception.

  1. Push the updated/fixed source code to your own repository.

Ok

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.