![]() |
.. (לתיקייה המכילה) | |
What should be the order of running test methods if a test class is marked as ORDERED, but some methods dont have order field on them? | |
The question was asked about the example test - it was fixed. |
When is a method considered to expect an exception? | |
When the test class it is in contains a (non static) field of type OOPExpectedException that is set with a value containing an exception. |
What exception type should the OOPTest annotation get? (as written in the pdf) | |
It shouldnt receive an exception as parameter. It was another mistake in the pdf, and it was fixed and re-uploaded. The expected exception mechanism replaced that field in the exception. OOPTest annotation should have two fields - order and tag. |
OOPExceptionRule Annotation should also be available at runtime. | |
This was not stated in the pdf - but it should be available at runtime (to find it from within your code). |
What should be the behavior when we expect an exception to be thrown, and no exception is thrown? | |
This is considered an Error. And the OOPResult should be Error, with the message that contains the class name of the exception that we were expecting to be thrown. |
Can there be more than one field annotated with @OOPExceptionRule ? | |
No. There can be at most one. Also, if there is a OOPExpectedException field in the class, you can assume that it is annotated with this rule annotation. |
Is there an order in which to run the test methods of the parent test classes in relation to the lowest test class? | |
No special order. Meaning: If the class being run is marked as ORDERED, then all test methods (including parent ones) are to be run in order. If the class is not marked (or marked with UNORDERED), then the test methods are to be run without order (meaning - you choose the order). |
If an OOPBefore or OOPAfter method fails, the result type should be ERROR. What should be the error message? | |
The name of the class of the exception that is thrown by the method. |
Is there a need to reset the data of OOPExpectedExceptionImpl after every test? | |
Yes. Every test should, by default, not expect any exception, and not expect any messages. |
Should the ExpectedException rule field be reset before every test method run? | |
Yes. Each test method should be run, not expecting an exception or exception messages, until code lines in the methods change that (using expect and expectMessage calls). For example - both of the following tests should pass: @OOPTest(order=1) public void f() { expected.expect(Exception.class).expectMessage("aa"); throw new Exception("aa"); } @OOPTest(order=2) public void g() {} |