Skip to content

Instantly share code, notes, and snippets.

@iRYO400
Created January 24, 2019 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iRYO400/e6fa5011371fc07d03803492479d09eb to your computer and use it in GitHub Desktop.
Save iRYO400/e6fa5011371fc07d03803492479d09eb to your computer and use it in GitHub Desktop.
Микромомент в юнит тестировании
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