Created
January 24, 2019 08:28
-
-
Save iRYO400/e6fa5011371fc07d03803492479d09eb to your computer and use it in GitHub Desktop.
Микромомент в юнит тестировании
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void checkCalculation() { | |
Product product = new Product(10, 10); | |
String totalSum = model.calculateSum(product); | |
String expected = "100 руб."; // #1 способ | |
assertThat(totalSum).isEqualTo(expected); // #1 способ | |
int expectedValue = getString(R.string.total_sum, 100); // #2 способ | |
assertThat(totalSum).isEqualTo(expectedValue); // #2 способ | |
} | |
public int calculateSum(Product product) { | |
int total = product.getCount * product.getPrice; | |
return getString(R.string.total_sum, total); | |
} | |
... | |
// Resources | |
<string name="total_sum">#%s руб.</string> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment