Skip to content

Instantly share code, notes, and snippets.

@trikitrok
trikitrok / ArgentRoseStore.java
Created February 1, 2026 22:25
Code after finding and fixing bugs
package com.argentrose;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public class ArgentRoseStore {
private final List<Product> inventory;
@trikitrok
trikitrok / ArgentRoseStore.java
Last active February 1, 2026 21:43
Production code with manual mutation that pit can't create
package com.argentrose;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;
public class ArgentRoseStore {
private final List<Product> inventory;
@trikitrok
trikitrok / ArgentRoseStoreTest.java
Last active February 2, 2026 16:45
Tests with no relevant mutants surviving but missing important test cases
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;
@trikitrok
trikitrok / ArgentRoseStoreTest.java
Last active February 2, 2026 16:44
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;
@trikitrok
trikitrok / ArgentRoseStoreTest.java
Last active February 2, 2026 16:40
Tests with 100% branch coverage but some relevant mutants surviving
package com.argentrose;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
public class ArgentRoseStoreTest {
@trikitrok
trikitrok / AdaptParameter4.java
Last active January 20, 2026 17:36
Refactoring Adapt Parameter example to better abstractions
interface LinePrinter {
void print(String line);
}
interface LibraryData {
String getLibraryName();
}
class ConsoleLinePrinter implements LinePrinter {
private final Console console;
class AcmeCompanyApi implements CompanyApi {
private readonly acmeCausesEndpoint: AcmeCausesEndpoint;
private readonly claimOpeningEndpoint: AcmeClaimOpeningEndpoint;
private readonly authTokenRetriever: AcmeAuthTokenRetriever;
constructor(config: AcmeApiConfig = new AcmeApiConfig()) {
this.acmeCausesEndpoint = new AcmeCausesEndpoint(config);
this.claimOpeningEndpoint = new AcmeClaimOpeningEndpoint(config);
this.authTokenRetriever = new AcmeAuthTokenRetriever(config);
}
class AcmeCompanyApi implements CompanyApi {
private readonly forGettingCauses: ForGettingCauses;
private readonly forOpeningClaim: ForOpeningClaim;
private readonly authTokenRetriever: AuthTokenRetriever;
constructor(config: AcmeApiConfig = new AcmeApiConfig()) {
this.forGettingCauses = new AcmeCausesEndpoint(config);
this.forOpeningClaim = new AcmeClaimOpeningEndpoint(config);
this.authTokenRetriever = new AcmeAuthTokenRetriever(config);
}
describe('AcmeCompanyApi', () => {
// some declarations
beforeEach(() => {
decoratedApi = {
open: jest.fn<Promise<OpeningResult>, [Claim]>()
};
api = new WithErrorHandlingCompanyApi(decoratedApi);
claim = aClaim(causeCodeInClaim);