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的更多相关文章

  1. jenkins+maven+junit构建自动化测试,整合junit xml生成直观的测试报告[留存]

    在自动化测试过程中,测试报告最能直观的体现测试的价值,之前一直使用maven+junit来构建我的自动化测试,但这样有几个缺点,一是,不能定时构建自动化任务(也许是我没有找到maven有没有提供这样的 ...

  2. [Java] Spring + SpringMVC + Maven + JUnit 搭建

    示例项目下载: https://github.com/yangyxd/SpringDemo 利用前面 SpringMVC 项目的配置方式,完成初步的项目创建.下面只讲一些不同之处. 传送门: [Jav ...

  3. spring && Cobertura && maven &&junit 单元测试以及测试覆盖率

    1. 目的:       junit 单元测试,Cobertura   测试覆盖率报告       项目目录结构          2. maven 配置     <project xmlns= ...

  4. maven junit 单元测试插件配置

    单元测试插件配置 pom.xml中增加 <dependency> <groupId>junit</groupId> <artifactId>junit& ...

  5. IntelliJ Idea + Maven + Junit

    Caculate.java package com.yxj.TestJunit; /** * Created by ubd on 15-4-17. */ public class Caculate { ...

  6. 传统项目目录结构下maven+junit+junitReport

    <build> <defaultGoal>compile</defaultGoal> <sourceDirectory>${basedir}/src&l ...

  7. maven junit.framework不存在问题解决

    问题 在使用maven进行一个工程的编译,已加入junit包的依赖,编译的时候却总是报“junit.framework不存在”错误. pom.xml中junit包加入如下: <dependenc ...

  8. junit+maven单元测试

    一.概念 junit是一个专门测试的框架 集合maven进行单元测试,可批量测试类中的大量方法是否符合预期 二.作用:单元测试:测试的内容是类中的方法,每一个方法都是独立测试的.方法是测试的基本单位. ...

  9. Maven生命周期,插件,单元测试junit

    maven生命周期,maven命令,maven插件 maven生命周期:就是maven构建项目的过程,清理,编译,测试,报告,打包,安装,部署 maven命令:maven独立使用,通过命令,完成mav ...

随机推荐

  1. Activity的四大启动模式

    在自己清单中的Activity里配置这四大启动之一. stander    标准模式   先进后出 singletop     会检查栈顶如果有,那么就复用,不会重新开启. singletask    ...

  2. 利用asynchttpclient开源项目来把数据提交给服务器

    可以通过github去查找asynchttpclient,并下载源代码,并加载到自己的工程中. 1.利用get方法提交 2.利用post方法来提交

  3. Lists.transform的使用

    转自:https://blog.csdn.net/weixin_42201566/article/details/81513769 Lists.transform:能够轻松的从一种类型的list转换为 ...

  4. CH4201 楼兰图腾

    题意 4201 楼兰图腾 0x40「数据结构进阶」例题 描述 在完成了分配任务之后,西部314来到了楼兰古城的西部.相传很久以前这片土地上(比楼兰古城还早)生活着两个部落,一个部落崇拜尖刀('V'), ...

  5. JAVA关闭钩子

    JAVA的关闭钩子: 1. 一般应用程序在关闭时都需要做一些善后清理工作,但是用户并不会总是按照推荐的方法关闭应用程序,比如用户直接关闭控制台程序或者按下Ctrl+C结束应用程序,这样就导致清理工作得 ...

  6. Java安全管理器

    启动SecurityManager开关: 隐式: 启动时添加JVM启动参数: -Djava.security.manager :启动默认的安全管理器: -Djava.security.policy=& ...

  7. package.json 文件中的版本号

    版本号,格式:"主要版本,次要版本,补丁版本" 指定版本:比如1.2.2,遵循"主版本,次要版本,补丁版本"的格式规定,安装时只安装指定版本. 波浪号(tild ...

  8. Connection: keep-alive,Content-Length,Transfer-Encoding: chunked,Content-Encoding: gzip等

    Transfer-Encoding,是一个 HTTP 头部字段,字面意思是「传输编码」. 用来改变报文格式,它不但不会减少实体内容传输大小,甚至还会使传输变大,那它的作用是什么呢?下面进行介绍. HT ...

  9. 数独求解程序 php版

    数独求解程序 php版 <?php class Sudoku { var $matrix; function __construct($arr = null) { if ($arr == nul ...

  10. linq to sql (Group By/Having/Count/Sum/Min/Max/Avg操作符) (转帖)

    http://wenku.baidu.com/link?url=2RsCun4Mum1SLbh-LHYZpTmGFMiEukrWAoJGKGpkiHKHeafJcx2y-HVttNMb1BqJpNdw ...