Skip to main content
Izrotech Logo

Testing a Fee Engine Across 19 eBay Marketplaces

How we test one fee engine per eBay marketplace: published worked examples, baseline snapshots, form-to-engine parity checks and round-trip price tests.

Izrotech

A fee calculator has an unusual failure mode: it can be wrong and look perfectly healthy. Nothing crashes, the page loads fast, and the number on the screen is a plausible number. The only way anyone finds out is by comparing it with an invoice. For the eBay Fees Calculator, which covers 19 marketplaces with different rates, tiers and seller types, that risk shaped how the code is organised and how it is tested. These are the practices that have earned their place.

One engine per marketplace

The tempting design is a single fee function driven by a big table of rates with a column per country. It is compact, and it couples every marketplace to every other one: a special case added for one country becomes a condition every other country's calculation passes through.

Each marketplace has its own engine instead: a small module that knows that country's rates, tiers, per-order fees and seller types, and nothing else. The engines share types and helpers, not rules. The cost is some repetition. The benefit is that a change to Germany's private-seller rules cannot alter a result in Australia, and a reviewer can read one file next to one fee page and check them against each other.

Rates as data, with the source beside them

Rates live in named constants in integer basis points, where 13.6% is 1,360, never as decimals scattered through the arithmetic. We keep a note of the fee page each set of rates came from and, where the page shows one, the date it was last updated. When a marketplace announces a change, the work starts from that note: which constants came from the page that changed.

Money is held in integer cents throughout, for the reasons set out in whole-cent integer math for fee and repricing engines.

Published worked examples become tests

Where eBay's own fee page works through an example sale, that example is copied into a test with its inputs and its expected fee. These are the most valuable tests in the suite, because they are the only ones whose expected value was not computed by us. A test that asserts "13.6% of 100.00 is 13.60" checks the multiplication. A test that reproduces the marketplace's own example checks that we understood the rule: which amount the percentage applies to, where a tier starts, and whether the per-order fee is added before or after.

Not every marketplace publishes examples. Where there are none, tests pin the boundaries instead: one cent below a tier threshold, exactly on it, and one cent above.

Baseline snapshots separate refactoring from rule changes

Before changing how the engines are structured, we record the full output of a fixed set of scenarios: every marketplace, each seller type, typical and awkward prices. After the change, the outputs must be identical, down to the cent and the wording of each fee line.

This sounds blunt, and that is its strength. A refactor is supposed to change nothing a seller can see, so any difference is a bug. A rule change is supposed to change specific results, so the snapshot diff shows exactly which results moved and the review becomes "are these the ones that should have moved, and by this much?" Mixing the two kinds of change in one commit throws that clarity away, so we do not.

Parity between the form and the engine

The engine is only half of a calculation. The other half is the form that decides which values reach it, and the two can disagree while each is correct by its own tests.

The classic case is a default. A form shows a category option labelled "Everything else" and sends a literal value for it. If the engine only treats a missing category as the default, that literal value falls through to a different branch, and a seller who never touched the category menu gets a different rate from the one the engine's tests cover. Each side passes its own tests; the sale is still wrong.

The answer is a parity test that takes its inputs from the form's own option lists: for every marketplace, every seller type and every category the interface can send, run the engine and check that the result is the one intended for that choice. It is a dull test to write. It is also the only test that sees the calculator the way a seller uses it.

Round-trip tests for anything that solves for a price

The calculator can work backwards from a target profit to the price that achieves it. A solver like that has a natural test: feed its answer back through the ordinary forward calculation.

  • At the suggested price, profit is at least the target.
  • At one cent less, it is not.

Run across every marketplace and seller type with a spread of costs, this catches rounding and tier-boundary mistakes that example-based tests miss, and it needs no hand-computed expected values at all. The same pair of checks is what a repricer's pricing rule must satisfy, as described in how eBay fees and ad rates compound against your margin.

Content is tested against the engine too

A fee guide that states a rate is one more place for a number to go stale. The figures in the calculator's guides, such as the final value fee comparison, are computed by the engines when the page is rendered, and tests compare the rates a guide prints with the engine's own. An article cannot then quote a fee the calculator no longer charges.

What tests cannot tell you

Tests prove that the code does what we believe the rules are. They cannot prove the belief is current. Marketplaces revise fees, sometimes with a few weeks of notice, and an engine that passes every test can still be describing last quarter. Three habits cover the gap:

  • Keep a record of the source and its date for every set of rates, and re-read the sources on a schedule.
  • Say plainly, in the product, that results are estimates and that the seller's own account is the authority.
  • Treat a seller's report of a mismatch as a test case: reproduce it with their marketplace, seller type, category and amounts, and add it to the suite once it is understood.

Checklist

  • Give each marketplace its own engine; share helpers, not rules.
  • Store rates as integer basis points, and record the source and its date.
  • Turn the marketplace's published examples into tests.
  • Snapshot outputs before a refactor and demand identical results after it.
  • Test every option the form can send, not only the ones the engine expects.
  • Round-trip every solver through the forward calculation.
  • Compute the numbers in your content from the engine.