• 【笔记】Eclipse and Java for Total Beginners—005


    Lesson 05 – JUnit Testing Continued

    • Test Person class – part 2
    • Create test methods for constructor, getName, and getMaximumBooks
    • Static methods

         这里的assertEquals是Static method.当其在所属的Class内部时,可略写Class。

    1 package org.totalbeginner.tutorial;
    2
    3  import org.totoalbeginner.tutorial.Person;
    4
    5 import junit.framework.TestCase;
    6
    7 public class PersonTest extends TestCase {
    8
    9 public void testPerson() {
    10 Person p1 = new Person();
    11 assertEquals("unknown name", p1.getName());
    12 assertEquals(3, p1.getMaximumBooks());
    13 }
    14
    15 public void testSetName() {
    16 Person p2 = new Person();
    17 p2.setName("Fred");
    18 assertEquals("Fred", p2.getName());
    19 }
    20
    21 public void testSetMaximumBooks() {
    22 Person p3 = new Person();
    23 p3.setMaximumBooks(10);
    24 assertEquals(10, p3.getMaximumBooks());
    25 }
    26
    27 }

  • 相关阅读:
    Maven name=archetypeCatalog value=internal
    ResponseBody和文件上传
    Idea控制台中文乱码
    idea tomcat部署项目路径
    git 常用操作
    webpack
    AbstractQueuedSynchronizer-AQS
    线程安全
    cpu多级缓存
    Axure中继器设置单选
  • 原文地址:https://www.cnblogs.com/halflife/p/2077264.html
Copyright © 2020-2023  润新知