SPM——Using Maven+Junit to test Hello Wudi
Last week, ours teacher taught us 'Software Delivery and Build Management'. And in this class, our teachers gave us a task about Develop the project “HelloWorld” and Install Maven and Build the “HelloWorld” Project. So I want to write something about using Maven and Junit.
1.Download Maven and configure environment variables

MAVEN_HOME: D:\apache-maven-3.3.1-bin\apache-maven-3.3.1
MAVEN: %MAVEN_HOME%\bin
PATH:%MAVEN%;
Then use cmd command 'mvn -v' to check the environment variables.

2.Using maven create your own project

After running this command, you will find that in the directory of C:/user/Anonymous, you have created your own project.
my-app-simple
|-- pom.xml
`-- src
|-- main
| `-- java
| `-- com
| `-- mycompany
| `-- app
| `-- App.java
`-- test
`-- java
`-- com
`-- mycompany
`-- app
`-- AppTest.java
3.Compile, test and package

This is compile command.


This is test command.


This is package command.
4.Import your project into Eclipse

Window->Preferences->Maven->Installations
Then add your maven into the Eclipse.
Import->Others->Maven->Existing Maven Projects


5.Download Junit and configure it

6.Write your own project code and test code
In App.java
package com.mycompany.app; /**
* Hello world!
*
*/
public class App
{
public String sayApp() {
return "Hello Wudi!";
} public static void main( String[] args )
{
App app = new App();
System.out.println( "Hello Wudi!" );
}
}
In AppTest.java
package com.mycompany.app; import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite; /**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
} /**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
} /**
* Rigourous Test :-)
*/
public void testApp()
{ App app = new com.mycompany.app.App();
assertEquals("Hello Wudi!", app.sayApp() );
}
}
Then you can run your project and get what you want.

That's all.
To be professional.
SPM——Using Maven+Junit to test Hello Wudi的更多相关文章
- jenkins+maven+junit构建自动化测试,整合junit xml生成直观的测试报告[留存]
在自动化测试过程中,测试报告最能直观的体现测试的价值,之前一直使用maven+junit来构建我的自动化测试,但这样有几个缺点,一是,不能定时构建自动化任务(也许是我没有找到maven有没有提供这样的 ...
- [Java] Spring + SpringMVC + Maven + JUnit 搭建
示例项目下载: https://github.com/yangyxd/SpringDemo 利用前面 SpringMVC 项目的配置方式,完成初步的项目创建.下面只讲一些不同之处. 传送门: [Jav ...
- spring && Cobertura && maven &&junit 单元测试以及测试覆盖率
1. 目的: junit 单元测试,Cobertura 测试覆盖率报告 项目目录结构 2. maven 配置 <project xmlns= ...
- maven junit 单元测试插件配置
单元测试插件配置 pom.xml中增加 <dependency> <groupId>junit</groupId> <artifactId>junit& ...
- IntelliJ Idea + Maven + Junit
Caculate.java package com.yxj.TestJunit; /** * Created by ubd on 15-4-17. */ public class Caculate { ...
- 传统项目目录结构下maven+junit+junitReport
<build> <defaultGoal>compile</defaultGoal> <sourceDirectory>${basedir}/src&l ...
- maven junit.framework不存在问题解决
问题 在使用maven进行一个工程的编译,已加入junit包的依赖,编译的时候却总是报“junit.framework不存在”错误. pom.xml中junit包加入如下: <dependenc ...
- junit+maven单元测试
一.概念 junit是一个专门测试的框架 集合maven进行单元测试,可批量测试类中的大量方法是否符合预期 二.作用:单元测试:测试的内容是类中的方法,每一个方法都是独立测试的.方法是测试的基本单位. ...
- Maven生命周期,插件,单元测试junit
maven生命周期,maven命令,maven插件 maven生命周期:就是maven构建项目的过程,清理,编译,测试,报告,打包,安装,部署 maven命令:maven独立使用,通过命令,完成mav ...
随机推荐
- python 兼容中文路径 + 目标文件是否是图像格式判断
1. 中文路径兼容python程序如果路径中包含中文字符,不加处理会有类似报错:'ascii' codec can't decode byte 0xxx in position xx:ordinal ...
- Potplayer快捷键
potplayer 滞后快捷键: x potplayer 滞后快捷键: c Crtl+C:截图到剪切板 Crtl+E:截图到安装目录Capture
- Word2007:如何在竖版(纵向)页面中间插入横版(横向)页面
通常情况下,我们在word排版过程中使用一种页面版式(横版/竖版)即可.但在某些特殊情况下,我们可能会需要在竖版页面中间插入一页或多页横版页面,抑或在横版页面中间插入竖版页面.那么,如何针对这 ...
- DoTween可视化编程用法详解
DoTween可视化编辑 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) Chinar -- 心分享.心创新 ...
- BZOJ3864: Hero meet devil【dp of dp】
Description There is an old country and the king fell in love with a devil. The devil always asks th ...
- 《DSP using MATLAB》Problem 4.8
代码: %% ---------------------------------------------------------------------------- %% Output Info a ...
- 原子性、可见性、synchronized 有好理解
原子性.可见性.synchronized 有好理解: from: https://blog.csdn.net/wohaqiyi/article/details/67635010 1.原子性 (1)原子 ...
- setTimeout设置为0的作用
调用方式:iTimerID = window.setTimeout(vCode, iMilliSeconds [, sLanguage])功能:Evaluates an expression afte ...
- test20190324 树
题意 树(tree.cpp/c/pas) [题目背景] 这道题标算在评测机上的时间约为自己电脑的2/3 [问题描述] [输入格式] 共 n+2 行.第 1 行 1 个数,n. 后面 2-n 行,每行两 ...
- Java中的内存泄露