Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active February 2, 2026 16:44
Show Gist options
  • Select an option

  • Save trikitrok/89b6733de848cb27167922ffbaf11270 to your computer and use it in GitHub Desktop.

Select an option

Save trikitrok/89b6733de848cb27167922ffbaf11270 to your computer and use it in GitHub Desktop.
Tests with no relevant mutants surviving
package com.argentrose;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
public class ArgentRoseStoreTest {
private static final int MIN_QUALITY = 0;
private static final int MAX_QUALITY = 50;
@Test
@DisplayName("Empty inventory stays empty after update")
void empty_inventory_stays_empty() {
ArgentRoseStore store = emptyStore();
store.update();
assertThat(store).isEqualTo(emptyStore());
}
@Test
@DisplayName("Updating a non expired regular product decreases its quality by 2 and decreases its sell-in by 1")
void not_expired_regular_product_update() {
ArgentRoseStore store = argentRoseStoreWith(regularProduct(1, 3));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(regularProduct(0, 1)));
}
@Test
@DisplayName("Non expired regular product's updated quality can not be negative")
void not_expired_regular_product_updated_quality_can_not_be_negative() {
ArgentRoseStore store = argentRoseStoreWith(regularProduct(30, 1));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(regularProduct(29, MIN_QUALITY)));
}
@Test
@DisplayName("Already expired regular product decreases quality twice as fast")
void already_expired_regular_product_update() {
ArgentRoseStore store = argentRoseStoreWith(regularProduct(0, 5));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(regularProduct(-1, 1)));
}
@Test
@DisplayName("Already expired regular product's updated quality can not be negative")
void already_expired_regular_product_updated_quality_can_not_be_negative() {
ArgentRoseStore store = argentRoseStoreWith(regularProduct(-1, 3));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(regularProduct(-2, MIN_QUALITY)));
}
@Test
@DisplayName("Theatre Passes increases quality by 1 when sell-in is greater than 6 days")
void theatre_passes_quality_increases_by_1_when_sellIn_greater_than_6() {
ArgentRoseStore store = argentRoseStoreWith(theatrePasses(7, 5));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(theatrePasses(6, 6)));
}
@Test
@DisplayName("Theatre Passes's quality can't grow over 50 when sell-in is greater than 6 days")
void theatre_passes_quality_cant_grow_over_50_when_sell_in_is_greater_than_6_days() {
ArgentRoseStore store = argentRoseStoreWith(theatrePasses(20, MAX_QUALITY));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(theatrePasses(19, MAX_QUALITY)));
}
@ParameterizedTest
@ValueSource(ints = {1, 6})
@DisplayName("Theatre Passes increases quality by 3 when sell-in is between 1 and 6 days")
void theatre_passes_quality_increases_by_3_when_sellIn_between_1_and_6(int sellIn) {
ArgentRoseStore store = argentRoseStoreWith(theatrePasses(sellIn, 46));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(theatrePasses(sellIn - 1, 49)));
}
@Test
@DisplayName("Theatre Passes quality can't grow over 50 when sell-in is between 1 and 6 days")
void theatre_passes_quality_cant_exceed_50_when_sellIn_between_one_and_six() {
ArgentRoseStore store = argentRoseStoreWith(theatrePasses(4, 48));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(theatrePasses(3, MAX_QUALITY)));
}
@Test
@DisplayName("Theatre Passes quality drops to 0 when expired")
void theatre_passes_quality_drops_to_0_when_expired() {
ArgentRoseStore store = argentRoseStoreWith(theatrePasses(0, 38));
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(theatrePasses(-1, MIN_QUALITY)));
}
@Test
@DisplayName("When there are several products each one is updated")
void when_there_are_several_products_each_one_is_updated() {
ArgentRoseStore store = argentRoseStoreWith(
theatrePasses(30, 5),
regularProduct(5, 3)
);
store.update();
assertThat(store).isEqualTo(argentRoseStoreWith(
theatrePasses(29, 6),
regularProduct(4, 1)
));
}
private Product theatrePasses(int sellIn, int quality) {
return new Product("Theatre Passes", sellIn, quality);
}
private Product regularProduct(int sellIn, int quality) {
return new Product("any not special product", sellIn, quality);
}
private ArgentRoseStore emptyStore() {
return argentRoseStoreWith();
}
private ArgentRoseStore argentRoseStoreWith(Product... products) {
return new ArgentRoseStore(Arrays.asList(products));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment