While using JMockit I want to throw an exception upon a constructor invocation like this:
new Expectations(){
{
new FirefoxDriver();//Want to throw IllegalStateException here but how?
}
};
To specify the result for a recorded expectation, assign it (either values to return or exceptions to throw) to the result
field:
new Expectations() {{
someMockedMethodOrConstructorInvocation(...); result = new IllegalStateException();
}};