測試學習 (一) JUnit測試框架和組合模式

2021-07-24 11:35:29 字數 549 閱讀 8017

測試用例:任何包含測試**的類(需要繼承testcase類)

composite模式(組合模式)

testcase相當於葉子節點。testsuite是非葉子節點,通過addtest方法,它可以包含自身,也可以包含testcase。原因是addtest方法的引數是test型別,而testsuite和testcase都實現了test介面。

test:測試介面

testsuite:測試套件,可包含多個test。

testcase:測試用例,test介面實現類。

testrunner:用來執行測試類。

setup:測試準備

teardown:測試後處理

test**:以test開頭,測試方法

run:會在其實現中呼叫setup,test**測試方法,和teardown方法

assert(「」==」「)等值比較

assertequals(「」,」「)物件比較

Junit測試框架簡介

test public void testrun package com.junittest import org.junit.after import org.junit.before import org.junit.test public class maintest test public ...

spring框架學習(三)junit單元測試

單元測試不是頭一次聽說了,但只是聽說從來沒有用過。乙個模組怎麼測試呢,是不是得專門為一單元寫乙個測試程式,然後將測試單元 拿過來測試?我是這麼想的。學到spring框架這才知道單元測試原來是這麼回事兒。set注入的第乙個例項為測試物件。進行單元測試。1,拷貝jar包 junit 3.8.2.jar ...

spring框架學習(三)junit單元測試

spring框架學習 三 junit單元測試 junit 3.8.2.jar 4.x主要增加註解應用 2.寫業務類 public class user public void setusername string username 新增方法 public string login throws ex...