Write JUnit 5 unit tests for Math.min(int, int).
Write JUnit 5 unit test for Math.cos(double).
Write JUnit 5 unit tests for String.concat(String)
Assume a class Sentence
implements class Iterable<String>
. Draw an object diagram that shows the relation between the instances of class Class
that represent Sentence
, Iterable
, Iterator
, and String
. Assume that all methods of class Class
that provide information about the class are getters for fields of the same name (e.g., there is a field interfaces
that matches method getInterfaces()
). Only use simple names for classes. Use the reflection API documentation and/or a debugger for help if necessary.
Using metaprogramming, write a program that takes two command-line arguments: the short name of a subtype of Number and a number literal, and that creates a new instance of that type that represents the number. For example, Integer
5
to represent 5 as an integer, or Double
5.1
to represent 5.1 as a double.
Using metaprogramming, verify whether it is possible to call any parameterless method of class String
on an empty string without raising an exception.
Write unit test for methods push
and pop
of class Stack. Use a fixture that you initialize before every test, and make sure your tests cover documented exceptional behavior.
Class PokerHand is a partial solution to exercise 3.9. Write a test class TestPokerHand
with helper methods than make it possible to test the private method isStraightFlush
, then write a test case for which the output is true
. For this method, how many executions of the UUT do we need to test it with all possible straight flushes? Does this mean we can achieve exhaustive test coverage with these test cases?
Extend your test suite for PokerHand to achieve complete statement coverage with a minimum number of executions of the UUT.
Extend your test suite for PokerHand to achieve complete branch coverage with a minimum number of executions of the UUT.
Write a test suite for all the public methods of class BiCardSource to achieve 100% branch coverage, using stubs to helps isolate the behavior to test.
Unless otherwise noted, the content of this repository is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Copyright Martin P. Robillard 2019-2021