第一章 軟體測試介紹

一、軟體測試行業介紹

目標:

    1.理解軟體測試的定義

    2.知道為什麼需要軟體測試

    3.知道為什麼選擇軟體測試

    4.知道為什麼不讓開發自c己做測試

注意:想進入軟體測試這一行,就要先了解測試行業的基本情況

1、軟體測試的定義

軟體測試:在規定的條件下對程式進行操作,以發現程式錯誤,衡量軟體品質,並對其是否能滿足設計要求進行評估的過程。

簡單地說:軟體測試是一種實際輸出和預期輸出之間的審核或者比較的過程。

2、為什麼需要軟體測試

每年軟體bug會讓整個市場經濟帶來近600億美元的損失!


3、為什麼選擇軟體測試

1.薪資高

2.市場需求量大

4、為什麼不讓開發自己做測試

    1.思維定式

    2.測試力度

    3.關注度

二、軟體測試核心課程介紹

目標:

    1.知道軟體測試的核心課程內容

1、功能測試

需求:針對TPshop項目的登錄模組進行功能測試


測試用例

注意:分為正向測試和逆向測試,也就是手工測試

  正向測試:按照正常的操作可以正常登錄成功

  逆向測試:故意輸入錯誤,檢查是否有錯誤提示

2、自動化測試

需求:針對TPshow項目的登錄模組實現自動化測試

import time
import unittest
from selenium import webdriver


class TestLogin(unittest.TestCase):
    """
    對登錄模組的功能進行測試
    """

    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(10)
        self.driver.get("//localhost/")

        # 點擊首頁的『登錄』鏈接,進入登錄頁面
        self.driver.find_element_by_link_text("登錄").click()

    def tearDown(self) -> None:
        self.driver.quit()

    def test01_login_success(self):
        """登錄成功"""

        # 輸入用戶名、密碼、驗證碼
        self.driver.find_element_by_id("username").send_keys("13012345678")
        self.driver.find_element_by_id("password").send_keys("123456")
        self.driver.find_element_by_id("verify_code").send_keys("8888")

        # 點擊『登錄』
        self.driver.find_element_by_name("sbtbutton").click()

        # 斷言提示資訊
        time.sleep(3)
        self.assertIn("我的賬戶", self.driver.title)

    def test02_login_username_is_not_exist(self):
        """帳號不存在"""

        # 輸入用戶名、密碼、驗證碼
        self.driver.find_element_by_id("username").send_keys("13099999999")
        self.driver.find_element_by_id("password").send_keys("123456")
        self.driver.find_element_by_id("verify_code").send_keys("8888")

        # 點擊『登錄』
        self.driver.find_element_by_name("sbtbutton").click()

        # 斷言提示資訊
        msg = self.driver.find_element_by_class_name("layui-layer-content").text
        print("msg=", msg)
        self.assertIn("帳號不存在", msg)

    def test03_login_password_is_error(self):
        """密碼錯誤"""

        # 輸入用戶名、密碼、驗證碼
        self.driver.find_element_by_id("username").send_keys("13012345678")
        self.driver.find_element_by_id("password").send_keys("error")
        self.driver.find_element_by_id("verify_code").send_keys("8888")

        # 點擊『登錄』
        self.driver.find_element_by_name("sbtbutton").click()

        # 斷言提示資訊
        msg = self.driver.find_element_by_class_name("layui-layer-content").text
        print("msg=", msg)
        self.assertIn("密碼錯誤", msg)

3、介面測試

需求:針對TPshow項目的登錄模組實現介面測試

 

4、性能測試

需求:針對TPshow項目,模擬實現100個用戶同時登錄系統

三、前置知識學習

目標

  1.知道學習軟體測試需要具備的基礎知識

1.學習軟體測試需要具備的基礎知識

為了更好的學習軟體測試的相關技能,需要具備一定的基礎知識,需要學習的基礎知識包括:

  • 電腦基礎
  • 前端知識
  • 後端知識
  • 軟體測試理論