如何为Bean Shell脚本编写像JUnit这样的单元测试用例

问题描述

我有一个Bean Shell脚本,我想知道如何编写像JUnit这样的测试用例?

解决方法

Beanshell项目在github上,您可以看到它正在使用JUnit进行测试

例如

@Test
public void testHashCode_contract() {
   final String name = "testMethod";
   final BshMethod method1 = new BshMethod(name,Integer.class,new String[0],new Class[0],new Modifiers[0],null,null);
   final BshMethod method2 = new BshMethod(name,null);    
   Assert.assertTrue("precondition check for test failed.",method2.equals(method1));
   Assert.assertEquals("Equal classes should have equal hashcodes",method2.hashCode(),method1.hashCode());
}

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...