You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Scala 2.12 and mockito-scala 1.14.4 (upgraded from 1.10.3 to verify bug)
Given a simple candidate for mocking:
case class Car(id: Int)
class VehicleService {
private var cars = Map.empty[Int, Car]
cars += (0 -> Car(0))
def getCar(id: Int): Option[Car] = cars.get(id)
def saveCar(car: Car) = {
cars += car.id -> car;
car
}
}
//test with IdiomaticMockito with ArgumentMatcherSugar mixed into Spec
val vehicleService = mock[VehicleService]
val error = new Exception("A wild exception appears")
error willBe thrown by vehicleService.getCar(any[Int])
will fail to compile unless getCar is annotated @throws(classDef[Exception])
Checked exception is invalid for this method!
Invalid: java.lang.Exception:
org.mockito.exceptions.base.MockitoException:
Checked exception is invalid for this method!
Invalid: java.lang.Exception:
alternative syntax
//test with IdiomaticMockito with ArgumentMatcherSugar
val vehicleService = mock[VehicleService]
val error = new Exception("A wild exception appears")
vehicleService.getCar(any[Int]) throws error
compiles and behaves as expected
The text was updated successfully, but these errors were encountered:
Using Scala 2.12 and mockito-scala 1.14.4 (upgraded from 1.10.3 to verify bug)
Given a simple candidate for mocking:
will fail to compile unless
getCar
is annotated@throws(classDef[Exception])
alternative syntax
compiles and behaves as expected
The text was updated successfully, but these errors were encountered: