/ Published in: Scala
                    
                                        
A simple Scala unit test example using FunSuite in scalatest. The test expects an exception.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
package scalaunittest
@RunWith(classOf[JUnitRunner]) // Run As | JUnit Test
/*
* This is a test. The test method takes two arguments.
* The first argument is the test name or description
* The second argument is a block of code to execute, that is, the test body.
*/
test("list length") {
// This is the way to expect an exception.
intercept[IndexOutOfBoundsException] {ls(5)}
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                