前段时间再写Spark例子的时候使用到了单元测试. 再次总结下.
Jar包引用 <!-- https://mvnrepository.com/artifact/junit/junit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>值得注意的是. @beforeClass与@AfterClass标示的方法需要声明为static类型的.
使用Assert.
Assert.assertNotNull(object); 不为空.Assert.assertArrayEquals(expecteds, actuals);数组相关.Assert.assertEquals(expected, actual); 对象相关.[1]. junit中@Before和@BeforeClass区别
