It's UWAweek 42 (2nd semester, week 12)

help5501

This forum is provided to promote discussion amongst students enrolled in CITS5501 Software Testing and Quality Assurance. If posting a question, it's suggested you check first whether your question is answered in the unit Frequently Asked Questions (FAQ) list, and use the search box (on the right) to see if an answer to your question has already been posted.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

Note that any posts must comply with the UWA Code of Conduct and the UWA Academic Conduct Policy. That means you should (a) treat everyone with respect and courtesy, and (b) not post your solutions to an assessment that's in progress.

If asking a programming question, it's recommended you read How do I ask a good question? If reporting or troubleshooting a bug in software used in the unit, it's recommend you read How to report bugs effectively.
Displaying selected article
Showing 1 of 143 articles.
Currently 84 other people reading this forum.


 UWA week 32 (2nd semester, week 3) ↓
SVG not supported

Login to reply

👍?
helpful
11:41am Thu 8th Aug, Arran S.

ANONYMOUS wrote:

> Hi professor, regarding Lab1 exercise 4 "Fix the code", the test codes for testSubtract() and testSubtractThrowsException().

Just "Arran", thanks.

> I am wondering if they are conflicting test cases? Since one should be asserting negative result and one is asserting for ArithmeticException for (can't return negative results). Therefore, isn't it not possible to make all the tests pass?

> Also testSubtractThrowsException() have num1 as 4 and num2 as 3, which shouldn't raise ArithmeticException. Based on the description ("can't return a negative result")

It looks like the test code has got out of sync with the lab worksheet at some point. The tests should be

  @Test
  public void testSubtract() {
      Calculator c = new Calculator(4, 3);
      int result = c.subtract();
      assertEquals(result, 1, "result should be 1");
  }

  @Test
  public void testSubtractThrowsException() {
      Calculator c = new Calculator(3, 4);
      Throwable exception = assertThrows(
          ArithmeticException.class, 
          () -> c.subtract()
      );
  }

I'll correct that.

Cheers

Arran

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy