Lab1

1.导入 JUnit,Hamcrest

Project -> Properites -> Java Build Path -> Add External JARs

 

 

2. 安装 Eclemma

Help -> Eclipse marketplace

搜索 Eclemma,点击Installed

 

 

3. 测试代码

TrianglePractice:

public class TrianglePractice {

    public TriangleType triangle(int a, int b, int c) {

        if (a+b<=c || a+c<=b || b+c<=a) return TriangleType.not_triangle;

 

        if (a==b) {

            if (b==c) return TriangleType.equilateral;

            else return TriangleType.isosceles;

        } else {

            if (b==c || a==c) return TriangleType.isosceles;

            else return TriangleType.scalene;

        }

    }

}

 

TriangleType:

public enum TriangleType {

not_triangle,equilateral,isosceles,scalene

}

 

TrianglePracticeTest:

import static org.junit.Assert.*;

 

import java.util.*;

 

import org.junit.*;

import org.junit.runner.RunWith;

import org.junit.runners.Parameterized;

import org.junit.runners.Parameterized.Parameters;

 

 

@RunWith(Parameterized.class)

public class TrianglePracticeTest {

    private TrianglePractice t=null;

    private int a,b,c;

    private TriangleType expected;

    

    public TrianglePracticeTest(List<Integer> list, TriangleType type) {

    a=list.get(0);

    b=list.get(1);

    c=list.get(2);

    expected=type;

    }

 

    @Before

    public void setUp() {

        t=new TrianglePractice();

    }

 

    @Parameters

    public static Collection<Object[]> getData() {

        return Arrays.asList(

            new Object[][] {

                {Arrays.asList(new Integer[]{2,2,2}),TriangleType.equilateral},//Path:1,3,4,6

                {Arrays.asList(new Integer[]{1,1,1}),TriangleType.equilateral},

                {Arrays.asList(new Integer[]{2,2,3}),TriangleType.isosceles},//Path:1,3,4,7

                {Arrays.asList(new Integer[]{2,2,1}),TriangleType.isosceles},

                {Arrays.asList(new Integer[]{2,3,2}),TriangleType.isosceles},//Path:1,3,5,8

                {Arrays.asList(new Integer[]{2,3,3}),TriangleType.isosceles},

                {Arrays.asList(new Integer[]{2,3,4}),TriangleType.scalene},//Path:1,3,5,9

                {Arrays.asList(new Integer[]{1,1,2}),TriangleType.not_triangle},//Path:1,2

                {Arrays.asList(new Integer[]{2,2,4}),TriangleType.not_triangle},

                {Arrays.asList(new Integer[]{2,3,6}),TriangleType.not_triangle},

            }

        );

    }

 

    @Test

    public void test() {

    assertEquals(t.triangle(a, b, c), expected);

    }

}

 

4. JUnit 测试结果

 

5. Eclemma 覆盖结果

 

 

转载于:https://www.cnblogs.com/matrota-hari/p/8647788.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/389977.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

抽象类细分举行_什么是用聚类技术聚类的客户细分

抽象类细分举行This content was originally posted in Spanish here https://blogs.solidq.com/es/poder-del-dato/que-es-el-clustering-segmenta-a-tus-clientes-con-machine-learning/此内容最初以西班牙语发布在此处https://blogs.solidq.com/es/poder-del-dato/que-es-el…

551. Student Attendance Record I 从字符串判断学生考勤

&#xff3b;抄题&#xff3d;&#xff1a; You are given a string representing an attendance record for a student. The record only contains the following three characters: A : Absent. L : Late.P : Present. A student could be rewarded if his attendance record…

使用deploy命令上传jar到私有仓库

打开cmd命令提示符&#xff0c;mvn install是将jar包安装到本地库&#xff0c;mvn deploy是将jar包上传到远程server&#xff0c;install和deploy都会先自行bulid编译检查&#xff0c;如果确认jar包没有问题&#xff0c;可以使用-Dmaven.test.skiptrue参数跳过编译和测试。 全命…

282. 给表达式添加运算符

282. 给表达式添加运算符 给定一个仅包含数字 0-9 的字符串 num 和一个目标值整数 target &#xff0c;在 num 的数字之间添加 二元 运算符&#xff08;不是一元&#xff09;、- 或 * &#xff0c;返回所有能够得到目标值的表达式。 示例 1:输入: num "123", targ…

java 在底图上绘制线条_使用底图和geonamescache绘制k表示聚类

java 在底图上绘制线条This is the third of four stories that aim to address the issue of identifying disease outbreaks by extracting news headlines from popular news sources.这是四个故事中的第三个&#xff0c;旨在通过从流行新闻来源中提取新闻头条来解决识别疾病…

python selenium处理JS只读(12306)

12306为例 js "document.getElementById(train_date).removeAttribute(readonly);" driver.execute_script(js)time2获取当前时间tomorrow_time 获取明天时间 from selenium import webdriver import time import datetime time1datetime.datetime.now().strftime(&…

Mac上使用Jenv管理多个JDK版本

使用Java时会接触到不同的版本。大多数时候我在使用Java 8&#xff0c;但是因为某些框架或是工具的要求&#xff0c;这时不得不让Java 7上前线。一般情况下是配置JAVA_HOME&#xff0c;指定不同的Java版本&#xff0c;但是这需要人为手动的输入。如果又要选择其他版本&#xff…

交互式和非交互式_发布交互式剧情

交互式和非交互式Python中的Visual EDA (Visual EDA in Python) I like to learn about different tools and technologies that are available to accomplish a task. When I decided to explore data regarding COVID-19 (Coronavirus), I knew that I would want the abilit…

5886. 如果相邻两个颜色均相同则删除当前颜色

5886. 如果相邻两个颜色均相同则删除当前颜色 总共有 n 个颜色片段排成一列&#xff0c;每个颜色片段要么是 ‘A’ 要么是 ‘B’ 。给你一个长度为 n 的字符串 colors &#xff0c;其中 colors[i] 表示第 i 个颜色片段的颜色。 Alice 和 Bob 在玩一个游戏&#xff0c;他们 轮…

Sunisoft.IrisSkin.SkinEngine 设置winform皮肤

Sunisoft.IrisSkin.SkinEngine se; se new Sunisoft.IrisSkin.SkinEngine { SkinAllForm true, SkinFile "..\..\skin\EmeraldColor2.ssk" };Sunisoft.IrisSkin.SkinEngine skin new Sunisoft.IrisSkin.SkinEngine(); //具体样式文件 地址&#xff0c;可以自行修…

docker 相关操作

docker-compose down //关闭所有容器 docker-compose up //开启所有容器docker-compose restart //重启所有容器单独更新某个容器时用脚本$ docker ps // 查看所有正在运行容器 $ docker stop containerId // containerId 是容器的ID$ docker ps -a // 查看所有容器 $…

电子表格转换成数据库_创建数据库,将电子表格转换为关系数据库,第1部分...

电子表格转换成数据库Part 1: Creating an Entity Relational Diagram (ERD)第1部分&#xff1a;创建实体关系图(ERD) A Relational Database Management System (RDMS) is a program that allows us to create, update, and manage a relational database. Structured Query …

【Vue.js学习】生命周期及数据绑定

一、生命后期 官网的图片说明&#xff1a; Vue的生命周期总结 var app new Vue({el:"#app", beforeCreate: function(){console.log(1-beforeCreate 初始化之前);//加载loading},created: function(){console.log(2-created 创建完成);//关闭loading},be…

5885. 使每位学生都有座位的最少移动次数

5885. 使每位学生都有座位的最少移动次数 一个房间里有 n 个座位和 n 名学生&#xff0c;房间用一个数轴表示。给你一个长度为 n 的数组 seats &#xff0c;其中 seats[i] 是第 i 个座位的位置。同时给你一个长度为 n 的数组 students &#xff0c;其中 students[j] 是第 j 位…

Springboot(2.0.0.RELEASE)+spark(2.1.0)框架整合到jar包成功发布(原创)!!!

一、前言 首先说明一下&#xff0c;这个框架的整合可能对大神来说十分容易&#xff0c;但是对我来说十分不易&#xff0c;踩了不少坑。虽然整合的时间不长&#xff0c;但是值得来纪念下&#xff01;&#xff01;&#xff01;我个人开发工具比较喜欢IDEA&#xff0c;创建的sprin…

求一个张量的梯度_张量流中离散策略梯度的最小工作示例2 0

求一个张量的梯度Training discrete actor networks with TensorFlow 2.0 is easy once you know how to do it, but also rather different from implementations in TensorFlow 1.0. As the 2.0 version was only released in September 2019, most examples that circulate …

docker环境 快速使用elasticsearch-head插件

docker环境 快速使用elasticsearch-head插件 #elasticsearch配置 #进入elk容器 docker exec -it elk /bin/bash #head插件访问配置 echo #head插件访问# http.cors.enabled: true http.cors.allow-origin: "*" >>/etc/elasticsearch/elasticsearch.yml#重启el…

476. 数字的补数

476. 数字的补数 给你一个 正 整数 num &#xff0c;输出它的补数。补数是对该数的二进制表示取反。 例 1&#xff1a;输入&#xff1a;num 5 输出&#xff1a;2 解释&#xff1a;5 的二进制表示为 101&#xff08;没有前导零位&#xff09;&#xff0c;其补数为 010。所以你…

zabbix网络发现主机

1 功能介绍 默认情况下&#xff0c;当我在主机上安装agent&#xff0c;然后要在server上手动添加主机并连接到模板&#xff0c;加入一个主机组。 如果有很多主机&#xff0c;并且经常变动&#xff0c;手动操作就很麻烦。 网络发现就是主机上安装了agent&#xff0c;然后server自…

python股市_如何使用python和破折号创建仪表板来主导股市

python股市始终关注大局 (Keep Your Eyes on the Big Picture) I’ve been fascinated with the stock market since I was a little kid. There is certainly no shortage of data to analyze, and if you find an edge you can make some easy money. To stay on top of the …