zoukankan      html  css  js  c++  java
  • junit在idea中的使用(1)--理论篇

     感觉本文前部分配置太过繁琐,大家可以参考我的这篇文章http://www.cnblogs.com/SuMeng/p/8279879.html(junit在IDEA中使用--实践篇),用添加maven依赖直接代替前面的配置,实践篇是基于spring的,本篇是针对普通项目,大家可以结合两篇来参考

    背景

    我在开发haoop时,IDEA自带的junit3不知道为什么不能用,所以改用junit4

    步骤

    添加插件:File->Settings->Plugins

    设置生成模式:File->Settings->Other Settings

    修改模板:File->Settings->Other Settings->Junit Generator->Junit4注意:还是把package 整行删掉吧!!!!!!!!!!!!!!!!!!!!!!

    方法一:右击类名-->goto-->test-->create test(此方法不需要上面的步骤)

    方法二:右击类名-->generate,直接就按照模板生成了(此方法需要上面的步骤)

     这是被测试的类HdfsClientDemo

    public class HdfsClientDemo {
        FileSystem fs = null;
        public void init() throws URISyntaxException, IOException, InterruptedException {
            Configuration conf = new Configuration();
            fs = FileSystem.get(new URI("hdfs://192.168.32.201:9000"),conf,"hadoop"); //最后一个参数为用户名
        }
        public void testUpLocalFile() throws IllegalArgumentException, IOException {
            fs.copyFromLocalFile(new Path("e:/kk.xml"),new Path("/laji.bal.copy111"));
            fs.close();
        }
        public void testDownLoad() throws IllegalArgumentException, IOException {
            fs.copyToLocalFile(new Path("/kk.xml.copy"), new Path("e:/BaiduYunDownload"));
            fs.close();
        }
        public static  void  main(String STR[]) throws URISyntaxException, IOException, InterruptedException {
            FileSystem fs = null;
            Configuration conf = new Configuration();
            fs = FileSystem.get(new URI("hdfs://192.168.32.201:9000"),conf,"hadoop");
            fs.copyFromLocalFile(new Path("e:/kk.xml"),new Path("/laji.bal.copy123"));
            fs.close();
        }
    }
    

    create new test后的样子

     

    需要自己添加上代码

  • 相关阅读:
    C++
    Qt简介
    C语言
    C/C++
    swagger2 Illegal DefaultValue null for parameter type integer
    maven包引入问题ClassNotFoundException: org.elasticsearch.client.Cancellable
    mysql自定义排序
    使用node创建服务器 运行vue打包的文件
    rsync实现服务器之间同步目录文件
    将jar包发布到maven的中央仓库细节整理
  • 原文地址:https://www.cnblogs.com/SuMeng/p/7862793.html
Copyright © 2011-2022 走看看