junit

SpringBoot系列: 单元测试2

会有一股神秘感。 提交于 2021-01-06 04:55:47
之前发了SpringBoot 单元测试的博客, https://www.cnblogs.com/harrychinese/p/springboot_unittesting.html , 内容较少, 现在补齐SpringBoot单元测试的主要知识点. 测试有很多种, 有单元测试 、集成测试 、冒烟测试 、回归测试 、端到端测试 、功能测试。 它们作用不同, 但又有所重叠. 1. 单元测试: [责任人: 开发人员]针对 class 级别的测试, 针对一个类, 写一个测试类. 在项目中, class 之间依赖调用是很常见的事情, 如果要测试的 classA, 又调用了classB, 这时候就没有遵守 "在一个class范围内测试", 自然不算单元测试, 应归为集成测试了. 不过这时候, 我们可以使用 mock 技术模拟被依赖的 classB, 这样整个测试又聚焦在classA 自身的功能, 所以又变回为单元测试. 2. 集成测试: [责任人: 开发人员]是单元测试在粒度上更进一步, 测试不同class之间的组合功能. 3. 冒烟测试: 可以理解为预测试, 一旦预测试失败(发现重大bug), 就直接停止测试, 打回给开发人员. 4. 回归测试: 重跑原有测试用例. ===================== spring-boot-starter-test 依赖包括: ==========

第十章 FISCO BCOS权限控制下的数据上链实操演练

蹲街弑〆低调 提交于 2021-01-06 02:05:45
想了解相关区块链开发,技术提问,请加QQ群:538327407 一、目的 前面已经完成FISCO BCOS 相关底层搭建、sdk使用、控制台、WeBASE中间件平台等系列实战开发, 本次进行最后一个部分,体系化管理区块链底层,建立有序的底层控管制度,实现权限化管理。 完成:链管理、系统管理、数据上链操作等。 其中数据上链分为:合约版本上链、crudService 版本上链等操作。 二、准备工作: 在进行之前,我们首先要了解一下,fisco bcos 的底层权限系统介绍。 https://mp.weixin.qq.com/s/QJNk71w4o_cGX2O-1aW29Q 三、设计理念差异 1、底层默认是可以部署合约,只有一旦操作 grantDeployAndCreateManager 命令,才开始限制用户部署合约权限 ps:一开始权限基本开放,而不是像常规系统设计那样,一开始权限为无,等到分配好权限才可以相应的的操作。 2、底层默认是写表操作,写表操作就有了CRUD等操作,常规的区块链体系是在不断区块打包过程中附加数据,FISCO BCOS 提供写表操作,实质上业务数据可以有修改的权限, 所以在链搭建好后,就必须限制Update等操作权限,并且在业务设计时候,需要多方去验证修改数据等过程,才可以防止区块链底层数据让高权限的人的篡改。 ps:与官方人员交谈,提供的例子

Ambiguous method call with Integer

橙三吉。 提交于 2021-01-05 06:37:40
问题 I am writing some Junit tests in Android, and if i do this: public void testSetId(){ Friend friend = new Friend(5); assertEquals(5,friend.getId()); } I get an ambiguous method call error. Ambiguous Method Call: Both AssertEquals(int, int) and AssertEquals(Object, Object) match Yet If i do this: public void testSetId(){ Integer ID = 5; Friend friend = new Friend(ID); assertEquals(ID, friend.getId()); } It works. I feel like the second function should be doing the exact same thing. What is

Getting scenario and steps undefined in cucumber with java

泪湿孤枕 提交于 2021-01-04 21:02:00
问题 I have been battling with this since 2 days. My test is shown passed but the test is not running in cucumber+java for Selenium webdriver test. In the console I am getting following message 1 Scenarios (1 undefined) 4 Steps (4 undefined) 0m0.000s You can implement missing steps with the snippets below: @Given("^User navigate to shopping page$") public void user_navigate_to_shopping_page() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new

Getting scenario and steps undefined in cucumber with java

浪尽此生 提交于 2021-01-04 20:58:11
问题 I have been battling with this since 2 days. My test is shown passed but the test is not running in cucumber+java for Selenium webdriver test. In the console I am getting following message 1 Scenarios (1 undefined) 4 Steps (4 undefined) 0m0.000s You can implement missing steps with the snippets below: @Given("^User navigate to shopping page$") public void user_navigate_to_shopping_page() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new

Getting scenario and steps undefined in cucumber with java

三世轮回 提交于 2021-01-04 20:49:36
问题 I have been battling with this since 2 days. My test is shown passed but the test is not running in cucumber+java for Selenium webdriver test. In the console I am getting following message 1 Scenarios (1 undefined) 4 Steps (4 undefined) 0m0.000s You can implement missing steps with the snippets below: @Given("^User navigate to shopping page$") public void user_navigate_to_shopping_page() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new

JAVA 基础编程练习题14 【程序 14 求日期】

孤街醉人 提交于 2021-01-04 04:05:04
14 【程序 14 求日期】 题目:输入某年某月某日,判断这一天是这一年的第几天? 程序分析:以 3 月 5 日为例,应该先把前两个月的加起来,然后再加上 5 天即本年的第几天,特殊情况, 闰年且输入月份大于 3 时需考虑多加一天。 package cskaoyan; public class cskaoyan14 { private static int year = 0; private static int month = 0; private static int day = 0; private static int[] leapYear = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private static int[] commonYear = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private int sum = 0; @org.junit.Test public void date() { java.util.Scanner in = new java.util.Scanner(System.in); year = in.nextInt(); month = in.nextInt(); day = in.nextInt(); try

LeetCode

元气小坏坏 提交于 2021-01-04 03:59:25
Topic String Description https://leetcode.com/problems/longest-common-prefix/ Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1 : Input: strs = ["flower","flow","flight"] Output: "fl" Example 2 : Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints : 0 <= strs.length <= 200 0 <= strs[i].length <= 200 strs[i] consists of only lower-case English letters. Analysis 略 Submission public class LongestCommonPrefix { // 方法一:我写的

LeetCode

守給你的承諾、 提交于 2021-01-04 02:54:25
Topic Math String Description https://leetcode.com/problems/roman-to-integer/ Roman numerals are represented by seven different symbols: I , V , X , L , C , D and M . Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one's added together. 12 is written as XII , which is simply X + II . The number 27 is written as XXVII , which is XX + V + II . Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII . Instead, the number four is written as IV . Because the one is before the

Code coverage does not reach class declaration

自古美人都是妖i 提交于 2021-01-02 06:16:30
问题 Is there any way to get the code coverage to cover the class declaration of a class like so? public class MyClass{ public static void foo(int bar){ System.out.println("The Number is: "+bar); } } I can easily hit the foo method with JUnit testing, but the MyClass declaration stays red. Is this because the class itself has no constructor? And if so, is there any way to cover that bit of code, without changing the code of the class itself? Thanks 回答1: This may depend on your specific environment