maven项目test编写

在maven项目中,可以在编译时对一些模块做测试。

项目目录为src/test/java

如下代码:

public class TestProperties {

	@Test
	public void testProperties() {
		JMproperties properties = new JMproperties();
		
		Assert.assertEquals("123456", properties.getDbPwd());
	}
}

这是测试我的JMproperties类,类里面是一些配置参数。在这里我测试是得到的DB密码是否为123456

测试

mvn clean test

测试通过。若把123456改为12345,则结果如下:

Failed tests:   testProperties(com.test.testproperties.TestProperties): expected:<12345[]> but was:<12345[6]>

Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.600s
[INFO] Finished at: Tue Jul 01 14:56:24 CST 2014
[INFO] Final Memory: 26M/258M
[INFO] ------------------------



你可能感兴趣的:(java)