使用 ChatGPT 變成更強大的軟體 QA 工程師

QA 是在軟體開發過程中,確保產品品質、穩定性和可靠性,從而提高使用者體驗、滿意度的職務。它涉及測試、撰寫測試案例、定義 BUG、追蹤 BUG、以及與開發團隊協調等,做為 QA,絕對是軟體開發過程中非常重要的一個環節。

QA 職能

  • 手動測試

    手動測試 QA,在台灣的軟體界,蠻大比例是屬於這部分職能(可能會寫程式的都被抓去當工程師!?)。手動測試通常是基於需求文件和設計文件,設計測試案例和測試方法,然後執行這些測試案例,檢查功能是否符合預期的要求和標準。手動測試QA 最大的價值與優點在於人力能夠發現自動測試無法發現的缺陷,而缺點自然是無法快速執行大規模、重複的測試需求,因此通常需要結合自動化測試進行綜合測試。

  • 自動測試

    自動測試通常使用自動化工具和腳本來執行測試案例。相比於手動測試,自動測試具有更快、更精確、更穩定的特點且能減少部分手動測試的人力成本。但是,自動測試也有一定的限制,例如無法測試新需求、圖像、影像和音樂等,且前期需要投入一定開發成本和資源。因此,實務上仍然需要結合手動測試和自動測試人員。

常見的謬誤

很多團隊都認為全面轉變為自動測試就不再需要手動測試QA了。
我認為這是一個非常嚴重的錯誤。首先,撰寫自動測試的前提是須要有完整的測試案例,這些測試案例都是需要人為優先撰寫的。
其次,一個新的功能開發出來,緊急狀態下絕對是手動先進行測試,絕對沒有時間撰寫自動測試,最後是是自動測試能夠測到的範圍絕對沒有手動來得廣泛與深入。

自動測試適用的範圍應該是確保每次佈署新內容時,沒有影響到既有的完整、主要功能
然而這樣的測試是非常 routine 且不可能每次佈署都做一次,這就能交給自動化測試,也就是 Acceptance Test

另一個主要情境是確保主要功能正常的測試,也可稱作On duty Test。假設你們的產品是 7*24 不停歇的服務,或是內容或穿插相依外部的服務,那會很適合這種測試模式。使用自動化腳本,定時走一輪主要功能,確保當下服務都正常。

因此,我們應該了解自動測試的優勢與優點在何處,而不是一昧的認為自動測試能夠取代手動。

藉由 ChatGPT 來加速 QA 職能的方式

ChatGPT 也許只是一項跨時代的產品,乘著智慧 AI,接受它,站在巨人的肩膀上才是未來之路。在這篇文章我將演示透過 ChatGPT 來輔助撰寫測試案例,進而大幅度提升 QA 的效能與產值。

ChatGPT 現階段無法給出 80 分的功能,但絕對能夠產生 60 分的輔助,剩下的,才是人工的價值。

我的目的是產生大部分情境適用的測試案例。

  1. 我先對 ChatGPT 建立情境,讓 AI 能夠融入、扮演這個腳色。
1
Assume you are a software QA and start to write test cases for a new feature.
  1. 再來是我希望它能夠產出我想要的內容與格式
1
2
Test scope must include happy path, exception cases and boundary tests.
Each test cases should contains test target, expected result and test scenarios.
  1. 接著我將仔細描述這個功能有什麼特性、選項。
    這是一個後台查詢報表的功能,並簡易的描述使用情境。
    此頁面有兩個篩選條件,一個是 查詢時間範圍,第二個是 品牌。
1
2
3
4
5
6
7
8
9
10
11
12
13
Here is the new feature.
User need to login backoffice first, then landing to report query page.

There are 2 filters:
1. DateRange. Allowing user to set Start and End date to query report.
This field is mandatory.
2. Brand. There are many brands' data in database.
This option allowing user to choose which brand to they want to see in this report.
If the filter is non-set, then default to query all brands data.

When user click the query button, then show the query result.

Focus on testing report query functionalities.
  1. 享受成果,以下是 ChatGPT 幫我撰寫出基礎的測試案例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Test Case 1: Happy Path

Test Target: Successfully query report with valid Date Range and Brand filter.

Test Scenario:

Login to backoffice.
Navigate to report query page.
Set Start and End Date range.
Select a specific brand from the Brand dropdown.
Click on the Query button.
Verify that the query result is displayed.
Verify that the result only contains data within the specified date range and brand filter.
Expected Result: Query result is displayed and contains data within the specified date range and brand filter.

Test Case 2: Exception Case

Test Target: Error message is displayed when Start Date is after End Date.

Test Scenario:

Login to backoffice.
Navigate to report query page.
Set Start Date to a date later than End Date.
Select a brand from the Brand dropdown.
Click on the Query button.
Expected Result: Error message is displayed indicating that the Start Date cannot be after the End Date.

Test Case 3: Boundary Test

Test Target: Query report with the maximum Date Range and all brands.

Test Scenario:

Login to backoffice.
Navigate to report query page.
Set the Start Date to the earliest date in the database.
Set the End Date to the latest date in the database.
Do not select any brand from the Brand dropdown.
Click on the Query button.
Verify that the query result is displayed.
Verify that the result contains all the data in the database.
Expected Result: Query result is displayed and contains all data in the database within the maximum date range and for all brands.

Test Case 4: Exception Case

Test Target: Error message is displayed when Date Range is not set.

Test Scenario:

Login to backoffice.
Navigate to report query page.
Do not set any value for the Date Range.
Select a brand from the Brand dropdown.
Click on the Query button.
Expected Result: Error message is displayed indicating that the Date Range is mandatory and needs to be set.

Test Case 5: Boundary Test

Test Target: Query report with the minimum Date Range and a specific brand.

Test Scenario:

Login to backoffice.
Navigate to report query page.
Set the Start and End Date to the same date.
Select a specific brand from the Brand dropdown.
Click on the Query button.
Verify that the query result is displayed.
Verify that the result contains data for the specified date and brand.
Expected Result: Query result is displayed and contains data for the specified date and brand.

結語

其實,當初撰寫這篇文章最主要的目的是幫助 QA 朋友們,告訴他們能夠透過 ChatGPT 來幫助他們建立出基本的測試案例,有了基本內容後,就能把時間和專注度放在更深層的、難以測試到的內容上,這樣才能展現出個人在這個工作岡位上的最大價值。

我想替 QA 朋友們解決的是工作上不必要、沒價值且重複的無聊工作,既然這個世代已經有跨時代的產品出現,我們應該敞開心胸接受、擁抱它,而不是一昧地拒絕或忽視,因為這樣做,最後被淘汰的,很可能只是跟不上時代的自己。我們透過 AI 來達到基礎的 60 分,剩下的就是發揮人類價值的地方。

最後,這個演示案例無論是功能還是結果都只是濃縮版。實務上功能絕對沒有這麼簡單或單純,而結果則是需要你不斷的客製化、修改給 ChatGPT 的請求,就能夠更快產出符合你需要的測試案例格式,當然,你也可以使用中文。

  • 作者: MingYi Chou
  • 版權聲明: 轉載不用問,但請註明出處!本網誌均採用 BY-NC-SA 許可協議。