title: How to test constraints on object initialization?
body: <p>I am writing an App for Android, and I am wanting to start writing tests for the classes I am writing. I am fairly new to writing test cases.</p>
  
  <p>Right now to create a test, I use IntelliJ and use it's wizard to make a new JUnit4 test. The wizard allows me to select methods from my class to test.</p>
  
  <p>But for the object I am testing, I do not want a negative number passed to the constructor. </p>
  
  <pre><code>class MinuteTime(private val minutes : Int) {
  init {
      if (minutes &lt; 0) {
          throw IllegalArgumentException("Cannot be less than 0.")
      }
  }
  ...
  </code></pre>
  
  <p>Where in my Test class is the best place to test these constraints? I know that to test the constraints, I just need to make sure the exception is thrown and caught, but I am unsure if I should make a new method for this, or just wedge it into one of the functions IntelliJ pre-made for me. Here is the generated test class:</p>
  
  <pre><code>class MinuteTimeTest {
      @Test
      fun getTimeInMinutes() {
  
      }
  
      @Test
      fun getHours() {
  
      }
  
      @Test
      fun getMinutes() {
  
      }
  
      @Test
      fun plus() {
  
      }
  }
  </code></pre>