QA and Test Automation · Lab 1 of 35
Write test cases for a checkout: partitions, boundary values and a real run
Set up ShopRung, read its checkout rules, find the partitions and boundaries, pick carts that land exactly on $50.00 and $75.00 with real prices, write 16 test cases, run them by hand, then switch three bugs on and see which cases catch them.
⏱ 60 minBeginner💸 Free7 steps
ShopRung (practice shop)Node.js 22.13+A web browsercurl or PowerShellA spreadsheet or text editor
Overview video
What you will build
A small, complete set of test documents for the checkout of a real (practice) shop: notes on the rules, a partition and boundary table, a test data sheet where every total is worked out, 16 test cases in a CSV file you can open in any spreadsheet, and a run log from two runs.
You will run every case by hand in ShopRung. Then you switch on three hidden bugs and run them again. Some cases fail, and you will see that only the cases sitting exactly on a boundary catch them. That one result is why testers learn boundary value analysis.
The setup on this page is the one every later lab uses, so you only do it once.
Before you start
- No coding needed. You need a computer where you can install programs and open a terminal.
- Helpful first (10 minutes each): Reading requirements, Equivalence partitioning and Boundary value analysis.
- How a test case is laid out: Test scenarios and test cases.
Setup
S1Install Node.js 22.13 or newer
ShopRung is a small web app that runs on Node.js, the program that runs JavaScript outside a browser. It needs version 22.13 or newer, because it uses the SQLite database built into Node. You do not need to know JavaScript.
Easiest on any system: download the LTS installer from nodejs.org and run it. Or use the command for your system below. macOS needs Homebrew for the command. On Windows, open PowerShell for every command in this lab.
brew install nodecurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejswinget install OpenJS.NodeJS.LTS S2Check the Node version
Open a new terminal window first, so it picks up the new program. It prints the version, for example v24.11.1. Any version from v22.13.0 up works.
node -v S3Download ShopRung and open its folder
ShopRung is the practice shop every lab in this track tests. You can click Download ShopRung and unzip it yourself, or run these commands. They make a folder called qa-labs in your home folder, download the zip into it, unzip it and move into the new shoprung folder.
ShopRung has nothing to install: it only uses what comes with Node.
mkdir -p ~/qa-labs && cd ~/qa-labs
curl -LO https://algorung.com/testing/shoprung.zip
unzip -o shoprung.zip
cd shoprungmkdir -p ~/qa-labs && cd ~/qa-labs
curl -LO https://algorung.com/testing/shoprung.zip
unzip -o shoprung.zip
cd shoprungNew-Item -ItemType Directory -Force ~\qa-labs | Out-Null; cd ~\qa-labs
Invoke-WebRequest https://algorung.com/testing/shoprung.zip -OutFile shoprung.zip
Expand-Archive shoprung.zip -DestinationPath . -Force
cd shoprung S4Start the shop
This terminal is now busy running the shop: leave it open. To stop the shop later, click in it and press Ctrl+C. Open a second terminal for the commands in the next steps.
npm start > shoprung@1.0.0 start > node --disable-warning=ExperimentalWarning src/server.js ShopRung is running at http://localhost:8080 API: http://localhost:8080/api/products SQL console: http://localhost:8080/sql
S5Open the shop and log in as Alice
Open http://localhost:8080 in your browser. You see 12 products, from a $4.99 sticker pack to $129.99 headphones.
Click Log in (top right). Type the email alice@shoprung.test and the password Alice123!, then click the Log in button. A message says Welcome back, Alice Shah and the top bar shows Hi, Alice Shah.
Now open http://localhost:8080/#/requirements. This is the list of rules the shop must follow, each with an id such as CART-2 or PRICE-9. Every test you write in this track points at one of these ids. (You can also reach it from the Requirements link at the bottom of every page.)
Two more practice accounts exist: bob@shoprung.test / Bob12345! (a customer) and admin@shoprung.test / Admin123! (an admin).
S6Reset the shop to its starting data
Run this in your second terminal. It deletes every change (carts, orders, new accounts, stock) and loads the starting data again, so every test starts from the same place. You stay logged in. Reload the browser page afterwards so it shows the fresh data.
On Windows, use the PowerShell command: in Windows PowerShell 5, curl is a different command and curl -X fails. PowerShell shows the same answer as a small table (status / reset) instead of JSON.
curl -X POST http://localhost:8080/api/test/resetcurl -X POST http://localhost:8080/api/test/resetInvoke-RestMethod -Method Post http://localhost:8080/api/test/reset {"status":"reset"} Read the checkout rules and write down your questions
Know exactly which rules you are testing, and what each one leaves unclear.
Open http://localhost:8080/#/requirements and read sections 3. Cart and 4. Prices, coupons and shipping. Read slowly. Testers find most problems by noticing what a sentence does not say.
For this lab you test five rules: CART-2 (quantity 1 to 10), PRICE-3 (SAVE10), PRICE-4 (FLAT5), PRICE-6 (rounding) and PRICE-9 (free shipping), plus PRICE-7 and PRICE-8, which say what happens when a coupon does not apply.
Make a folder for your work, for example checkout-tests, and create the file below in any text editor. Copy each rule in your own words, then write the questions a careful reader would ask. Some have answers in the text; some you would ask the product owner at work.
# Checkout rules under test (ShopRung requirements 1.0)
Money is in US dollars. Subtotal = price x quantity for every line, before discount and shipping.
| Id | Rule in my words |
| --- | --- |
| CART-2 | Each cart line holds 1 to 10 of a product. Adding more to a line still stops at 10. |
| PRICE-3 | SAVE10 takes 10% off when the subtotal is $50.00 or more. |
| PRICE-4 | FLAT5 takes $5.00 off when the subtotal is $20.00 or more. |
| PRICE-6 | A percentage discount rounds to the nearest cent. Half a cent rounds up. |
| PRICE-7 | An unknown code is refused with "No coupon called <CODE>". |
| PRICE-8 | If the cart changes so a saved coupon no longer applies, the cart says why and drops it. |
| PRICE-9 | Shipping is free when the subtotal AFTER the discount is $75.00 or more, else $4.99. |
| PRICE-10 | Total = subtotal - discount + shipping. |
## Questions
1. "$50.00 or more": so exactly $50.00 gets the discount. (Answered: yes, "or more".)
2. PRICE-9 says "after the discount". So $80.00 with FLAT5 ($75.00) ships free, and
$75.00 with FLAT5 ($70.00) does not. Is that what the business wants? (Ask.)
3. CART-2: what happens with 0, a blank box, -1 or 2.5? The rule only says 1 to 10.
4. CART-2: "adding more ... still cannot go above 10". Is the whole add refused,
or is the line capped at 10? (Not stated. Note what the shop does.)
5. PRICE-8: does the coupon come back by itself if the cart goes back up to $50.00?
6. Coupon codes are not case-sensitive (PRICE-2), so save10 should work too. - A table of the rules you test, in your words. If you cannot restate a rule simply, you do not understand it yet, and neither might the developer.line 5
- "AFTER the discount" is the most important word on the page. Many people test free shipping with the subtotal only.line 13
- An answered question is still worth writing down: it tells you exactly where the boundary is and which side is valid.line 18
- Values the rule does not mention are where bugs hide. You will test 0 here; blank and decimals are good extra cases.line 21
- Question 5 has a real answer you can find: the coupon stays saved, so it applies again when the subtotal returns to $50.00. Try it after step 5.line 24
Find the partitions and the boundaries
For each rule, the groups of inputs that behave the same, and the exact edges between them.
Equivalence partitioning: split the possible inputs into groups (partitions) the rule treats the same way. One test from each group is enough, because every value in a group should behave alike.
Boundary value analysis: bugs cluster at the edges between groups, where a developer typed > instead of >=. So for each edge, test the value on it and the value just past it. With money in cents, "just past $50.00" is $49.99.
Write this table. Each row is one rule; the last column is the values you will actually test.
# Partitions and boundaries
| Rule | Input | Invalid / no effect | Valid / applies | Edge | Values to test |
| --- | --- | --- | --- | --- | --- |
| CART-2 | quantity on one line | 0 or less; 11 or more | 1 to 10 | 1 and 10 | 0, 10, 11 (1 is used in many cases) |
| CART-2 | quantity added to a line | new total above 10 | new total 10 or less | 10 | 6 + 5 = 11 |
| PRICE-3 | subtotal with SAVE10 | $0.01 to $49.99 | $50.00 and up | $50.00 | $49.99, $50.00 |
| PRICE-4 | subtotal with FLAT5 | $0.01 to $19.99 | $20.00 and up | $20.00 | $19.99, $20.00 |
| PRICE-6 | 10% of the subtotal | | | half a cent | a subtotal ending in 5 cents |
| PRICE-8 | cart with a saved coupon | falls below the minimum | stays at or above | $50.00 | $50.00 down to $37.50 |
| PRICE-9 | subtotal after discount | $0.01 to $74.99 ($4.99 shipping) | $75.00 and up (free) | $75.00 | $74.99, $75.00 |
| PRICE-9 | ... reached through a coupon | $75.00 - $5.00 = $70.00 | $80.00 - $5.00 = $75.00 | $75.00 | both |
| PRICE-7 | coupon code | unknown code | SAVE10, FLAT5 | | SAVE20 |
Two-value boundary analysis: for each edge, the value on the edge and the
nearest value on the other side. One cent is the smallest step for money. - Two invalid partitions (too few, too many) and one valid one. Each edge gets the value on it and the value just outside.line 5
- The pair that matters most: $49.99 must be refused and $50.00 must be accepted. A cart of $60.00 tells you nothing about the edge.line 7
- Rounding is a boundary too: the edge between rounding down and rounding up is exactly half a cent.line 9
- The same edge reached two ways. A developer who used the subtotal instead of the after-discount amount passes one of these and fails the other.line 12
- Some testers also add the value one step inside (three-value analysis): 1, 2, 9, 10, 11. Two-value is enough for this lab.line 15
Stuck on this step?
- Why not test $50.01 as well?
- It is in the same partition as $50.00 (the discount applies). If $50.00 works, $50.01 almost certainly does too. The values worth a test are the ones on each side of the edge.
Pick carts that hit each boundary with real prices
A test data sheet: for each boundary, the exact cart that lands on it, and the total worked out by hand.
A boundary is only useful if you can reach it. You cannot type a subtotal; you have to build a cart from the real prices. Open http://localhost:8080, note the price of every product, and find combinations that land exactly on $50.00, $49.99, $20.00, $19.99, $75.00 and $74.99.
Then work out every expected total yourself, with the rules from step 1: total = subtotal - discount + shipping. Do not copy the totals from the shop. A test whose expected result came from the app can never fail.
# Test data (ShopRung seed data)
## Prices (from the Products page, after a reset)
| Id | Product | Price | Stock |
| --- | --- | --- | --- |
| 1 | Clean Code Notebook | $12.50 | 40 |
| 4 | Green Build Mug | $15.00 | 60 |
| 6 | Ship It T-Shirt | $20.00 | 30 |
| 7 | Works On My Machine Hoodie | $49.99 | 12 |
| 8 | Quiet Mechanical Keyboard | $75.00 | 8 |
| 9 | Wireless Mouse | $25.50 | 20 |
| 11 | Sticker Pack: Edge Cases | $4.99 | 200 |
## Carts and expected totals
| Cart | Subtotal | Coupon | Discount | After discount | Shipping | Total |
| --- | --- | --- | --- | --- | --- | --- |
| 4 x Notebook | $50.00 | SAVE10 | $5.00 | $45.00 | $4.99 | $49.99 |
| 1 x Hoodie | $49.99 | SAVE10 (refused) | $0.00 | $49.99 | $4.99 | $54.98 |
| 5 x Sticker + 1 x Mouse | $50.45 | SAVE10 | $5.05 | $45.40 | $4.99 | $50.39 |
| 3 x Notebook (was 4) | $37.50 | SAVE10 (dropped) | $0.00 | $37.50 | $4.99 | $42.49 |
| 1 x T-Shirt | $20.00 | FLAT5 | $5.00 | $15.00 | $4.99 | $19.99 |
| 1 x Mug + 1 x Sticker | $19.99 | FLAT5 (refused) | $0.00 | $19.99 | $4.99 | $24.98 |
| 1 x Keyboard | $75.00 | none | $0.00 | $75.00 | Free | $75.00 |
| 1 x Hoodie + 2 x Notebook | $74.99 | none | $0.00 | $74.99 | $4.99 | $79.98 |
| 4 x T-Shirt | $80.00 | FLAT5 | $5.00 | $75.00 | Free | $75.00 |
| 1 x Keyboard | $75.00 | FLAT5 | $5.00 | $70.00 | $4.99 | $74.99 |
| 10 x Sticker | $49.90 | none | $0.00 | $49.90 | $4.99 | $54.89 |
| 1 x Notebook | $12.50 | SAVE20 (unknown) | $0.00 | $12.50 | $4.99 | $17.49 |
Rounding: 10% of $50.45 is $5.045. Half a cent rounds up, so $5.05 (PRICE-6). - Write down the stock too. Stock is another boundary (CART-3): The Bug Hunter's Diary has only 3, a good extra case.line 4
- $12.50 x 4 is exactly $50.00: the cheapest way onto the SAVE10 edge.line 17
- The Hoodie at $49.99 sits one cent below the edge. Real shops price things like this on purpose, so this cart is not far-fetched.line 18
- Every seed price ends in 0 or 9 cents, so only a cart with five items ending in 9 gives a subtotal ending in 5 cents. Five $4.99 stickers do it.line 19
- Two different carts with the same $75.00 subtotal: one ships free, one does not. Only the amount after the discount decides.line 26
- Rounding rules are easy to get wrong in code (rounding down, or floating-point money). Always have one case with half a cent.line 30
Write the test cases
16 test cases in a CSV file, each one specific enough that someone else could run it and get the same result.
Create test-cases.csv in your text editor (or a spreadsheet, saved as CSV). One row per case, with seven columns: id, requirement (the rule id), title, preconditions (what must be true before you start), steps, test data and expected result.
A good expected result is a fact you can check in one look: the exact message, and the exact amounts. "Discount works" is not an expected result; "discount -$5.00, total $49.99" is.
Fields that contain a comma are wrapped in double quotes; that is how CSV keeps them in one cell. Open the file in a spreadsheet to read it as a table.
id,requirement,title,preconditions,steps,test data,expected result
TC-01,CART-2,Quantity 10 is accepted (top of the valid range),"Logged in as alice, empty cart","1) Open the product page 2) Type 10 in Quantity 3) Click Add to cart 4) Open the cart","Sticker Pack: Edge Cases (/#/product/11), quantity 10","Toast: Added to cart. Cart count 10. Line total $49.90. Subtotal $49.90, shipping $4.99, total $54.89"
TC-02,CART-2,Quantity 11 is refused (just above the range),"Logged in as alice, empty cart","1) Open the product page 2) Type 11 in Quantity 3) Click Add to cart","Sticker Pack: Edge Cases (/#/product/11), quantity 11","Red toast: Quantity must be between 1 and 10. Cart count stays 0"
TC-03,CART-2,Quantity 0 is refused (just below the range),"Logged in as alice, empty cart","1) Open the product page 2) Type 0 in Quantity 3) Click Add to cart","Sticker Pack: Edge Cases (/#/product/11), quantity 0","Red toast: Quantity must be between 1 and 10. Cart count stays 0"
TC-04,CART-2,Adding to a line cannot take it above 10,"Logged in as alice, empty cart","1) Open the product page 2) Add quantity 6 3) Add quantity 5 4) Open the cart","Sticker Pack: Edge Cases (/#/product/11), 6 then 5","Second add shows the red toast: Quantity must be between 1 and 10. The cart line stays at 6 ($29.94)"
TC-05,CART-2,Changing a cart line to 11 is refused,"Logged in as alice, cart has 10 x Sticker Pack: Edge Cases (as after TC-01)","1) Open the cart 2) Type 11 in the Quantity box 3) Press Tab","Quantity 10 changed to 11","Red toast: Quantity must be between 1 and 10. The box shows 10 again and the line total stays $49.90"
TC-06,PRICE-3,SAVE10 works at exactly $50.00,"Logged in as alice, empty cart","1) Add 4 x Clean Code Notebook 2) Open the cart 3) Type SAVE10 in Coupon code 4) Click Apply","4 x Clean Code Notebook ($12.50) = $50.00","Toast: Coupon applied. Subtotal $50.00, discount -$5.00, shipping $4.99, total $49.99"
TC-07,PRICE-3,SAVE10 is refused at $49.99,"Logged in as alice, empty cart","1) Add 1 x Works On My Machine Hoodie 2) Open the cart 3) Apply SAVE10","1 x Hoodie ($49.99) = $49.99","Red toast: This coupon needs a subtotal of at least $50.00. Discount -$0.00, shipping $4.99, total $54.98"
TC-08,PRICE-6,SAVE10 rounds half a cent up (code typed in lower case),"Logged in as alice, empty cart","1) Add 5 x Sticker Pack: Edge Cases and 1 x Wireless Mouse 2) Open the cart 3) Apply save10","5 x $4.99 + 1 x $25.50 = $50.45. 10% = $5.045","Toast: Coupon applied. Subtotal $50.45, discount -$5.05, shipping $4.99, total $50.39"
TC-09,PRICE-8,SAVE10 stops applying when the cart drops below $50.00,"Logged in as alice, cart as after TC-06 (4 x Clean Code Notebook, SAVE10 applied)","1) Open the cart 2) Change the notebook quantity from 4 to 3 3) Press Tab","Subtotal goes from $50.00 to $37.50","Message next to the coupon: This coupon needs a subtotal of at least $50.00. Discount -$0.00, shipping $4.99, total $42.49"
TC-10,PRICE-4,FLAT5 works at exactly $20.00,"Logged in as alice, empty cart","1) Add 1 x Ship It T-Shirt 2) Open the cart 3) Apply FLAT5","1 x Ship It T-Shirt ($20.00) = $20.00","Toast: Coupon applied. Subtotal $20.00, discount -$5.00, shipping $4.99, total $19.99"
TC-11,PRICE-4,FLAT5 is refused at $19.99,"Logged in as alice, empty cart","1) Add 1 x Green Build Mug and 1 x Sticker Pack: Edge Cases 2) Open the cart 3) Apply FLAT5","$15.00 + $4.99 = $19.99","Red toast: This coupon needs a subtotal of at least $20.00. Discount -$0.00, shipping $4.99, total $24.98"
TC-12,PRICE-9,Shipping is free at exactly $75.00,"Logged in as alice, empty cart","1) Add 1 x Quiet Mechanical Keyboard 2) Open the cart","1 x Keyboard ($75.00), no coupon","Subtotal $75.00, discount -$0.00, shipping Free, total $75.00"
TC-13,PRICE-9,Shipping costs $4.99 at $74.99,"Logged in as alice, empty cart","1) Add 1 x Works On My Machine Hoodie and 2 x Clean Code Notebook 2) Open the cart","$49.99 + 2 x $12.50 = $74.99, no coupon","Subtotal $74.99, discount -$0.00, shipping $4.99, total $79.98"
TC-14,PRICE-9,Free shipping uses the amount after the discount ($75.00 after FLAT5),"Logged in as alice, empty cart","1) Add 4 x Ship It T-Shirt 2) Open the cart 3) Apply FLAT5","4 x $20.00 = $80.00, minus $5.00 = $75.00","Subtotal $80.00, discount -$5.00, shipping Free, total $75.00"
TC-15,PRICE-9,A discount can take the cart below free shipping,"Logged in as alice, empty cart","1) Add 1 x Quiet Mechanical Keyboard 2) Open the cart 3) Apply FLAT5","$75.00 minus $5.00 = $70.00","Subtotal $75.00, discount -$5.00, shipping $4.99, total $74.99"
TC-16,PRICE-7,An unknown coupon is refused by name,"Logged in as alice, cart has 1 x Clean Code Notebook","1) Open the cart 2) Type SAVE20 in Coupon code 3) Click Apply","Code SAVE20 (does not exist)","Red toast: No coupon called SAVE20. Discount -$0.00, shipping $4.99, total $17.49" - The seven columns most test-case tools use. The requirement id links every case back to a rule, so you can show which rules are covered.line 1
- The valid edge: 10 must work. Product 11 is the $4.99 sticker pack, which has 200 in stock, so stock never gets in the way.line 2
- One past the edge. The product page has a Quantity box you can type 11 into, so this is reachable from the UI.line 3
- The "adds to that line" part of CART-2. A check on the quantity sent (5) but not on the new line total (11) passes TC-02 and fails this one.line 5
- The single most important coupon case: exactly on the edge, on the side that must work.line 7
- One case can cover two rules: lower-case "save10" checks PRICE-2 (codes are not case-sensitive) while the amount checks rounding.line 9
- This case depends on TC-06. Dependent cases are quicker to run, but if TC-06 fails, this one cannot run at all ("blocked").line 10
- Same $75.00 edge as TC-12, reached through a coupon. Together they prove the shop uses the after-discount amount.line 15
Stuck on this step?
- My spreadsheet puts everything in one column
- Import the file instead of opening it: in most spreadsheets choose File > Import, then pick comma as the separator and double quote as the text delimiter.
Run every case by hand
Run all 16 cases against ShopRung and record what really happened.
Before each case, reset the shop in your second terminal with the command at the end of this step, and reload the page. That gives you an empty cart and no coupon. TC-05 and TC-09 continue from TC-01 and TC-06, so run each of those straight after, without a reset.
How to do the steps in the shop: open a product by clicking its name, or go straight to its page (http://localhost:8080/#/product/11 is the sticker pack; the number is the product id from your test data). Type the amount in Quantity and click Add to cart. Open the cart with Cart in the top bar. Type a code in Coupon code and click Apply. To change a quantity in the cart, type the new number in its box and press Tab.
Messages appear for four seconds at the bottom of the page: red for an error, dark for success. Compare each amount in the cart with your expected result, and write Pass only if every part matches. Write what you actually saw in the third column, even for a pass.
id,run 1 (no bugs),run 1 actual
TC-01,Pass,"Count 10, line $49.90, total $54.89"
TC-02,Pass,"Toast: Quantity must be between 1 and 10, count 0"
TC-03,Pass,"Toast: Quantity must be between 1 and 10, count 0"
TC-04,Pass,"Second add refused, line stays 6 ($29.94)"
TC-05,Pass,"Refused, box back to 10, line $49.90"
TC-06,Pass,"Coupon applied, -$5.00, total $49.99"
TC-07,Pass,"Refused: needs at least $50.00, total $54.98"
TC-08,Pass,"Coupon applied, -$5.05, total $50.39"
TC-09,Pass,"Message: needs at least $50.00, -$0.00, total $42.49"
TC-10,Pass,"Coupon applied, -$5.00, total $19.99"
TC-11,Pass,"Refused: needs at least $20.00, total $24.98"
TC-12,Pass,"Shipping Free, total $75.00"
TC-13,Pass,"Shipping $4.99, total $79.98"
TC-14,Pass,"Shipping Free, total $75.00"
TC-15,Pass,"Shipping $4.99, total $74.99"
TC-16,Pass,"Toast: No coupon called SAVE20, total $17.49" - A run log keeps the cases unchanged and records each run separately. The same cases run again next release, so the cases file should not change every time.line 1
- Under CART-2 the shop refuses the whole add and keeps the line at 6. That answers question 4 from step 1.line 5
- This is how PRICE-8 looks in the UI: the coupon code stays in the box, with a red message next to it, and the discount is $0.00.line 10
curl -X POST http://localhost:8080/api/test/resetcurl -X POST http://localhost:8080/api/test/resetInvoke-RestMethod -Method Post http://localhost:8080/api/test/reset {"status":"reset"} Stuck on this step?
- The cart still shows items from the last case after a reset
- The reset worked, but the page was drawn before it. Reload the page (F5, or Cmd+R on a Mac).
- The page says Please log in
- A login lasts 2 hours (ACC-7). Log in as Alice again. Your cart is kept.
- Clicking Add to cart on the Products page always adds 1
- That button adds one at a time. For a larger quantity, open the product page and type it in the Quantity box.
Switch three bugs on and run again
Find out which of your cases catch real boundary bugs.
ShopRung has a bug switch: known bugs you can turn on to check that your tests would catch them. Turn on three bugs. Do not look up what they do yet: that is what your tests are for.
A yellow bar appears at the top of the shop: Bug switch on: coupon-boundary, free-shipping-boundary, quantity-limit. A reset does not turn bugs off, so you can keep resetting between cases as before.
Run all 16 cases again and fill in the run 2 columns. If a precondition cannot be set up, the case is Blocked, not passed or failed.
The command that turns the bugs on is at the end of this step, below the run log. Run it first. (PowerShell shows the answer as a table instead of JSON; look for the three names under active.)
id,run 1 (no bugs),run 1 actual,run 2 (3 bugs on),run 2 actual
TC-01,Pass,"Count 10, line $49.90, total $54.89",Pass,Same as run 1
TC-02,Pass,"Toast: Quantity must be between 1 and 10, count 0",FAIL,"Toast: Added to cart. Count 11, line $54.89"
TC-03,Pass,"Toast: Quantity must be between 1 and 10, count 0",Pass,Same as run 1
TC-04,Pass,"Second add refused, line stays 6 ($29.94)",FAIL,Second add accepted. Line is 11 ($54.89)
TC-05,Pass,"Refused, box back to 10, line $49.90",FAIL,Accepted. Line is 11 ($54.89)
TC-06,Pass,"Coupon applied, -$5.00, total $49.99",FAIL,Red toast: This coupon needs a subtotal of at least $50.00. Total $54.99
TC-07,Pass,"Refused: needs at least $50.00, total $54.98",Pass,Same as run 1
TC-08,Pass,"Coupon applied, -$5.05, total $50.39",Pass,Same as run 1
TC-09,Pass,"Message: needs at least $50.00, -$0.00, total $42.49",Blocked,Precondition failed: SAVE10 cannot be applied at $50.00 (see TC-06)
TC-10,Pass,"Coupon applied, -$5.00, total $19.99",Pass,Same as run 1
TC-11,Pass,"Refused: needs at least $20.00, total $24.98",Pass,Same as run 1
TC-12,Pass,"Shipping Free, total $75.00",FAIL,"Shipping $4.99, total $79.99"
TC-13,Pass,"Shipping $4.99, total $79.98",Pass,Same as run 1
TC-14,Pass,"Shipping Free, total $75.00",FAIL,"Shipping $4.99, total $79.99"
TC-15,Pass,"Shipping $4.99, total $74.99",Pass,Same as run 1
TC-16,Pass,"Toast: No coupon called SAVE20, total $17.49",Pass,Same as run 1 - The shop now accepts 11. TC-01 (quantity 10) still passes: only the case just past the edge sees the bug.line 3
- SAVE10 at exactly $50.00 is refused, and the message even contradicts itself ("at least $50.00" on a $50.00 cart). Note the exact text for the bug report.line 7
- $49.99 still passes. This bug moved the edge by one cent, so the case below the edge cannot see it.line 8
- Blocked, not failed: the bug is in TC-06. Counting it as a second failure would make one bug look like two.line 10
- Free shipping now needs more than $75.00. Your $75.00 cart pays $4.99.line 13
- The same bug found the second way. A $90.00 "free shipping" cart would have passed and hidden it.line 15
curl -X POST http://localhost:8080/api/test/bugs -H "Content-Type: application/json" -d '{"enabled":["coupon-boundary","quantity-limit","free-shipping-boundary"]}'curl -X POST http://localhost:8080/api/test/bugs -H "Content-Type: application/json" -d '{"enabled":["coupon-boundary","quantity-limit","free-shipping-boundary"]}'Invoke-RestMethod -Method Post http://localhost:8080/api/test/bugs -ContentType "application/json" -Body '{"enabled":["coupon-boundary","quantity-limit","free-shipping-boundary"]}' {"mystery":false,"active":["coupon-boundary","free-shipping-boundary","quantity-limit"],"known":{...}} Stuck on this step?
{"error":"bad_request","message":"Send {\"enabled\": [\"bug-name\", ...]} ..."}- The JSON did not arrive. On macOS and Linux keep the single quotes around the
-dvalue. On Windows use the PowerShell command above. - No yellow bar
- Reload the shop page. The bar is drawn each time a page opens.
Read the result, then turn the bugs off
Turn the two runs into findings: which technique caught which bug, and what the suite still misses.
Now check your guesses: open http://localhost:8080/api/test/bugs. The known list describes every bug. Match each of your failures to one of the three you switched on.
Write the findings below. Then turn every bug off, so the next lab starts from a correct shop.
# Findings: checkout test cases, two runs
Run 1, bugs off: 16 of 16 passed.
Run 2, three bugs on: 9 passed, 6 failed, 1 blocked.
| Bug switched on | Caught by | Missed by |
| --- | --- | --- |
| coupon-boundary (SAVE10 needs more than $50.00) | TC-06 ($50.00) | TC-07 ($49.99), TC-08 ($50.45) |
| quantity-limit (a line accepts 11) | TC-02, TC-04, TC-05 | TC-01 (10), TC-03 (0) |
| free-shipping-boundary (free only above $75.00) | TC-12, TC-14 ($75.00) | TC-13 ($74.99), TC-15 ($70.00) |
## What this shows
- Every bug was caught only by a case sitting exactly on the edge, on the
side that should be valid. A typical "happy path" cart ($60, $90) passes.
- TC-10 and TC-11 (FLAT5) stayed green. No FLAT5 bug was switched on, so
that is the right result: a pass means this run found nothing there.
- TC-09 was blocked by the TC-06 bug. Independent cases give clearer results.
## Not covered yet
- CART-3 stock: add 4 of The Bug Hunter's Diary (stock 3) -> "Only 3 left".
- CART-2 with a blank quantity, -1 or 2.5.
- Placing the order (ORD-1): does the order keep the same totals? - Report the counts first. A reader should know the outcome of a run from the first lines.line 4
- The heart of the lab: the case below the edge and the case well above it both missed the bug. Only the value on the edge caught it.line 8
- This is the real lesson of boundary value analysis, measured on your own suite instead of taken on trust.line 13
- Every suite has gaps. Writing them down turns them into the next test cases instead of surprises.line 19
curl -X POST http://localhost:8080/api/test/bugs -H "Content-Type: application/json" -d '{"enabled":[]}'curl -X POST http://localhost:8080/api/test/bugs -H "Content-Type: application/json" -d '{"enabled":[]}'Invoke-RestMethod -Method Post http://localhost:8080/api/test/bugs -ContentType "application/json" -Body '{"enabled":[]}' {"mystery":false,"active":[],"known":{...}} Check it works
Your lab is done when every item below is true:
ShopRung runs at http://localhost:8080, you can log in as Alice, and
/api/test/resetanswers{"status":"reset"}.test-cases.csvhas 16 cases, every one with a requirement id and an expected result with exact amounts or an exact message.Every expected total in your test data was worked out by hand, and run 1 passed all 16.
Run 2, with the three bugs on, failed TC-02, TC-04, TC-05, TC-06, TC-12 and TC-14, and blocked TC-09.
The bugs are off again. This command shows an empty
activelist:
curl http://localhost:8080/api/test/bugscurl http://localhost:8080/api/test/bugsInvoke-RestMethod http://localhost:8080/api/test/bugs {"mystery":false,"active":[],"known":{...}} Troubleshooting
npm start says Error: listen EADDRINUSE: address already in use with port 8080
Something else uses port 8080, often a ShopRung you started earlier in another window. Stop that one with Ctrl+C, or start on another port: PORT=8081 npm start (PowerShell: $env:PORT=8081; npm start) and use http://localhost:8081 everywhere.
No such built-in module: node:sqlite
Your Node.js is older than 22.13. Run node -v, install the current LTS from nodejs.org, and open a new terminal.
npm error Missing script: "start" or Could not read package.json
You are not in the shoprung folder. Run cd ~/qa-labs/shoprung (or wherever you unzipped it) and try again. Some browsers unzip downloads by themselves, so the folder may already be in your Downloads folder.
Windows: Invoke-WebRequest : A parameter cannot be found that matches parameter name 'X'
In Windows PowerShell 5, curl is another name for Invoke-WebRequest. Use the PowerShell commands on this page, or type curl.exe instead of curl.
My totals do not match the shop, even with the bugs off
Reset first: an old cart or a saved coupon from an earlier case changes the numbers. Then check your sums: shipping depends on the amount after the discount, not the subtotal.
The yellow bug bar is still there after a reset
That is by design: a reset restores the data, not the bug switch. Turn the bugs off with {"enabled":[]} (step 7), or stop and start the shop.
What changes in production
- Cases live in a test management tool, such as TestRail, Xray or Zephyr in Jira, or in the repository next to the code. A CSV like yours imports into most of them.
- Every case points at a requirement id or a ticket. That gives a traceability report: which rules have cases, which have none, and which failed in the last run.
- Testers review the requirements and the boundaries with the developer and product owner before coding starts. Questions like "after the discount?" are cheapest to answer then.
- Boundary cases are the first ones automated. The checkout totals become API tests and unit tests (later labs), so the manual time goes to exploratory testing instead.
- Each test starts from known data. Teams use a reset endpoint, a fresh database or seeded test accounts, just like
/api/test/reset.
Interview angle
“How would you test a rule like "free shipping on orders of $75 or more"?”
First I would clarify the rule: $75 before or after discounts, before or after tax, and whether it is "or more" or "over". Then I would split the input into two partitions, paid shipping and free shipping, and put cases on the boundary: exactly $75.00, which must be free, and $74.99, which must not. If a discount applies first, I would reach the same edge through a coupon too, for example $80 minus $5. I would build those carts from real prices and work out the expected totals myself. In ShopRung that exact pair caught a bug where the code used "greater than" instead of "greater than or equal". Once the manual cases are right, I would automate them at the API or unit level, because they will need to run on every change.
Clean up
Keep ShopRung and your checkout-tests folder: the next lab, an exploratory session, uses both. To stop the shop, press Ctrl+C in the terminal where it runs. Next time, cd ~/qa-labs/shoprung and npm start again; your data is kept in data/shoprung.db until you reset.
Practice
These run in your browser and check your answer.
Work out the expected total
Write expected_total(subtotal, code) with ShopRung's rules, in cents (so $50.00 is 5000). code is "SAVE10", "FLAT5" or None. SAVE10: 10% off from 5000, rounded to the nearest cent with half a cent rounding up. FLAT5: 500 off from 2000. A coupon below its minimum gives no discount. Shipping is 499, or 0 when the amount after the discount is 7500 or more. Return the total in cents.
def expected_total(subtotal, code):
discount = 0
if code == "SAVE10" and subtotal > 5000:
discount = subtotal // 10
if code == "FLAT5" and subtotal >= 2000:
discount = 500
shipping = 0 if subtotal >= 7500 else 499
return subtotal - discount + shipping
print(expected_total(5000, "SAVE10")) # should be 4999
Hint
The starter has three boundary bugs, the same kind ShopRung's bug switch adds: the SAVE10 comparison, the rounding (`// 10` always rounds down; try `(subtotal * 10 + 50) // 100`), and shipping, which must use the amount after the discount.
Generate the boundary values
Write boundary_values(lo, hi, three=False) for a rule "valid from lo to hi". Two-value analysis returns the values on each edge and just outside: [lo - 1, lo, hi, hi + 1]. With three=True, also add the values just inside: lo + 1 and hi - 1. Return a sorted list with no duplicates.
def boundary_values(lo, hi, three=False):
values = [lo, hi]
return values
print(boundary_values(1, 10))
Hint
Collect the values in a set (so duplicates disappear), then return `sorted(...)` of it.
The full project
Every worksheet from this lab, filled in as an example. Do your own first, then compare.