Eclipse下对MAVEN进行junit软件测试

一、Maven project management and build automation tool, more and more developers use it to manage the project jar. This article describes how Eclipse installation, configuration and use Maven.(This article draws on the experience of Wu Di students, but most of the steps are different from his writing, I have personally been completed.)

二、test environment:win7 Ultimate + ADT-Eclipse

三、First you have to make sure that you have configured the JAVA environment, learning software must believe it will not be unfamiliar, the Internet can easily search for an installation article will not repeat them here.

四、MAVEN environment configuration:go to 官网 download mawen files,extract to the root directory of your expectations, and then configure the environment variables.

  Updates about the configuration:

  MAVEN_HOME: D:\apache-maven-3.3.1(I chose to unpack in the D drive)

  MAVEN: %MAVEN_HOME%\bin

  PATH:%MAVEN%;(Plus an additional note in the back of PATH;)

五、Open the console,input mvn -v

  

  The following interface proved successful installation.

六、Use "compile,test,package" to build the project

  1.First ,input

$mvn archettype:generate

Then it will download the file of maven.

After a while,Then it reminds you enter groupID and some data, you can fill in according to your own situation.i will give a example.

  groupId: com.company.app

  artifactId:my-app-simple

  version:1.0

  ...push enter to continue.

  last it says bilud success,and in your in the directory of C:/user/yourname 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

  2.input

$cd my-app-simple
$mvn compile

  push Enter

  3.test,input:

$mvn test

  

  4.package ,input:

  

$mvn package 

  Still show BUILD SUCCESS.

  Your maven project so far has been built.

七、eclipse maven plugin installed(if you already had,then jumped this step)

  You can goto the following blog and get a eclipse maven plugin.THERE,and you download the file with my baidu cloud share.                http://pan.baidu.com/s/1kTvdteJ

八、import the project you build.

  open you eclipse,and choose Import->Others->Maven->Existing Maven Projects .

THEN choose Properties->Java Build Path ->ADD library->Junit.

十、write your app.java and apptest.java

app.java:

package com.mycompany.app;

/**
 * Hello world!
 *
 */
public class App
{
    public String sayApp() {
        return "Hello WangHui_3012218097!";
    }

    public static void main( String[] args )
    {
        App app = new App();
        System.out.println( "Hello WangHui_3012218097!" );
    }
}

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 WangHui_3012218097!", app.sayApp() );
    }
}

IN THE END

choose  Run as->Junit Test

and the result in there:

if your work have no problem ,then you have did it.

十一、Summary

  it‘s a good way to do the junit test,and under the maven we have a better enviroment to manager a team.so ,professional tool will make you effective.

时间: 2024-10-24 06:48:20

Eclipse下对MAVEN进行junit软件测试的相关文章

Eclipse下新建Maven项目、自动打依赖jar包

当我们无法从本地仓库找到需要的构件的时候,就会从远程仓库下载构件至本地仓库.一般地,对于每个人来说,书房只有一个,但外面的书店有很多,类似第,对于Maven来说,每个用户只有一个本地仓库,但可以配置访问很多远程仓库. Eclipse *版本 Eclipse *下载 强烈推荐书籍:Maven实战   许晓斌著.目前是第一版 注意:最新版本的Eclipse代号Mars,已经直接集成了Maven,所以无需安装m2Eclipse插件. Eclipse下新建Maven项目 1.下载Maven安装包 进入M

Eclipse 下用Maven构建ssh框架web工程

之前的项目中用到了maven,而且是web项目(但不是标准的ssh架构),趁着假期,重用南哥的pom文件,自己也试试用maven构建web项目,搭建完整的ssh开发框架. 工具准备:jdk,eclipse,maven Eclipse 插件:Hibernate Tools (以上工具软件请请自行Google下载安装) 当然,构建过程需要畅通的网络,以确保maven能顺利下载依赖包. 第一步,在eclipse新建Maven项目, New->Maven Project: 两个next之后选择maven

在Eclipse下使用Maven创建SpringMVC样例项目

1,新建maven项目,项目名起为:MavenSpringMVC. 具体步骤参见我的上一篇博客:在eclipse下使用Maven创建Struts2项目样例 2,配置pom.xml文件,引入依赖包(当然,我也不是一开始就知道需要引入哪些包的,我一开始也只是引入了Spring的核心包,后面发现缺包了就再补上) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/200

eclipse下新建maven项目

eclipse下新建maven项目 1.1下载maven安装包 进入Maven官网的下载页面:http://maven.apache.org/download.cgi,如下图所示:\ 选择当前最新版本:"apache-maven-3.3.9-bin.zip",下载到本地,解压缩到本地磁盘下. 1.2 配置 修改默认的本地仓库位置 进入Maven安装目录下的conf子目录中,打开settings.xml进行配置修改. Maven默认的本地仓库位置是当前用户工作目录下的".m2/

eclipse下SpringMVC+Maven+Mybatis+MySQL项目搭建

这篇文章主要讲解在eclipse环境下SpringMVC+Maven+Mybatis+MySQL的项目搭建过程. 创建Maven工程. 右击-->New->Other 点击->Manven Porject 点击->勾选快速框架 输入项目名,包(Packaging,如果只是普通的项目,选jar就好了,如果是web项目就选war,这里是web项目,所以选择war) 右击项目->Properties->Java Build Path->选择Libraries->点

5.Maven和Eclipse整合(两种方式进行插件的安装),Maven相关设置,Eclipse下创建Maven项目

 1  第一种方式是:在连网的情况下,通过在helpàInstall下安装. 新的地址是:http://download.eclipse.org/technology/m2e/releases 2  第二中方式是: 通过插件配置的方式进行安装插件. A  将maven所需的插件放到maven的安装目录下,截图如下: B 在Eclipse的dropins目录下创建以下三个插件: 三个文件中的内容分别是: m2e.txt path=E:/Installed/apache-maven-3.1.0/

eclipse下创建maven项目并部署到tomcat服务器(转)

maven项目部署到服务器有很多方法,可以利用jetty-maven-plugin或者tomcat-maven-plugin,这属于maven的知识点. 通常开发中,需要将项目放在服务器上借助开发工具进行调试,这里就写一下在eclipse中创建maven项目,并将它改造使之能够部署到集成在eclipse中的tomcat上面. 1.点击File-->New-->Project,选择Maven Project,点击Next 2  选择项目所在的java working set ,点击Next 3.

Eclipse下面的Maven管理的SSH框架整合(Struts,Spring,Hibernate)

搭建的环境:eclispe下面的maven web项目 Struts:    2.5.10 Spring:    4.3.8 Hibernate:   5.1.7 .Final MySQL:   5.1.30 先来详细的讲解一下SSH框架的整合,在这里是将struts2.0的Action的创建工作由Spring进行统一管理,主要是利用了Spring 控制反转和依赖注入的功能. 而将hibernate.cfg.xml整合Spring的配置文件中.而且利用Spring的面向切向功能对Hibernat

eclipse下创建maven管理

一.搭建环境 1.1JDK jdk配置就不用多说了吧.直接在电脑环境变量path下加上JDK安装路径 1.2eclipse 安装eclipse 1.3 maven 1,3.1配置maven环境变量 校验maven环境变量是否配置成功 1.3.2 eclipse配置maven插件 Help->Eclipse Marketplace搜索关键字maven到插件Maven Integration for Eclipse 并点击安装即可 记得要重启.这时候我们需要将此处安装的maven与上面配置的mave