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 }

  • 相关阅读:
    C++ 四种cast 用法
    Wannafly挑战赛1 B Xorto
    python里的闭包
    编译器对类的编译顺序
    class和struct
    typedef类型别名
    decltype类型指示符
    左值和右值
    const限定符
    hdu5678 树上第k小
  • 原文地址:https://www.cnblogs.com/halflife/p/2077264.html
Copyright © 2011-2022 走看看