EvaluateBeanshell rule = new EvaluateBeanshell();
rule.condition = "${env} == null";
rule.message = "We have a variable : ${env}";
ExpressionEvaluator eval = mock( ExpressionEvaluator.class );
when( eval.evaluate( rule.condition ) ).thenThrow( new ExpressionEvaluationException( "expected error" ) );
try
{
EnforcerRuleHelper helper = EnforcerTestUtils.getHelper( project, eval );
rule.execute( helper );
fail( "Expected an exception." );