スキップしてメイン コンテンツに移動

投稿

ラベル(Parameterized Test)が付いた投稿を表示しています

Automated Testing: Parameterized Test

In the previous post , I introduced basic of Unit Testing. Next I introduce parameterized testing. Before explaning parameterized testing, let's define a simple service class which uses ExchangeRateApi calss. package com.dukesoftware.exchangerate.service; import java.util.HashMap; import java.util.Map; import com.dukesoftware.exchangerate.api.ExchangeRateApi; import com.dukesoftware.exchangerate.api.Rate; public class PriceCalculator { private final ExchangeRateApi api; private final Map<String, Rate> map = new HashMap<>(); private final static double FEE_RATE = 0.05; public PriceCalculator(ExchangeRateApi api) { this.api = api; } public void initialize() { } public void shutdown() { this.map.clear(); } public double calculatePrice(double price, String ccy1, String ccy2) { Rate rate = this.map.get(ccy1+":"+ccy2); if(rate == null) { // cac