Test valid state transitions with scalacheck

8 views
Skip to first unread message

Pablo Fernandez

unread,
Jun 2, 2016, 10:31:01 AM6/2/16
to scalacheck

Suppose I have this class:


case class Receipt(id: Long, state: String) {
  def transitionTo(newState: String) = {
    if (!canTransitionTo(newState)) {
       throw new IllegalStateExcetion(s"cant transition from $state to $newState")
    }
    this.copy(state = newState)
  }
}


I'd like to test the logic in canTransitionTo (not included here for the sake of simplicity) with scalachecks Commands but I'm having a bit of trouble on how to begin. Any ideas?


(I've posted this same question is on stackoverflow, just in case someone wants the extra points)

Reply all
Reply to author
Forward
0 new messages