• 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后的样子

     

    需要自己添加上代码

  • 相关阅读:
    Android-setDefaultKeyMode方法
    Andorid-Fragment生命周期
    X210(s5pv210)中断系统
    X210串口配置与stdio移植
    SoC时钟系统简介
    SDRAM初始化
    重定位与链接脚本
    裸机配置C语言运行环境
    ARM汇编程序闪烁灯与其反汇编代码比较
    Makefile的简单使用
  • 原文地址:https://www.cnblogs.com/SuMeng/p/7862793.html
Copyright © 2020-2023  润新知