zoukankan      html  css  js  c++  java
  • 【笔记】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 }

  • 相关阅读:
    2019.8.15刷题统计
    2019.8.12刷题统计
    2019.8.11刷题统计
    2019.8.10刷题统计
    2019.8.9刷题统计
    2019.8.8刷题统计
    2019.8.7刷题统计
    2019.8.6刷题统计
    xuezhan.org 6.28
    xuezhan.org 6.27
  • 原文地址:https://www.cnblogs.com/halflife/p/2077264.html
Copyright © 2011-2022 走看看