Skip to content

Instantly share code, notes, and snippets.

@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 June 6, 2026 19:28
Tests with no relevant mutants surviving not 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 June 6, 2026 18: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) {
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) {
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);
class WithErrorHandlingCompanyApi implements CompanyApi {
constructor(private readonly decoratedApi: CompanyApi) {
}
async open(claim: Claim): Promise<OpeningResult> {
try {
return await this.decoratedApi.open(claim);
} catch (e) {
if (e instanceof CannotRetrieveTokenError) {
return OpeningResult.failed(claim, 'Acme API: failure retrieving token');
class AcmeCompanyApi implements CompanyApi {
constructor(
private readonly forGettingCauses: ForGettingCauses,
private readonly forOpeningClaim: ForOpeningClaim,
private readonly authTokenRetriever: AuthTokenRetriever) {
}
async open(claim: Claim): Promise<OpeningResult> {
const token = await this.authTokenRetriever.retrieveToken();
const causes = await this.forGettingCauses.getAllFor(claim, token);