Kotlinlearncs.online LogoJava
Return to List

Test Writing: Person Encourager

Created By: Geoffrey Challen
/ Version: 2020.10.0

Create a class Person that stores a private String name set by the constructor. (Reject null names using require.) Person should also declare a companion object with a single method named encourage. encourage should accept a single Person parameter and return a String containing some encouragement in the form: "(name), you are not alone!".

So here is how Person should work:

Test Design Challenge

You're challenge is to write tests for this problem described above.

  • Provide a public class named TestPerson with a single non-private class method named test that accepts no arguments and does not return a value.
  • If the implementation of the class described above is incorrect, your test method should throw an exception.
  • If it is correct, do not throw an exception.
  • You may want to use Kotlin's assert or check methods