package de.codecentric.jbehave.junit.monitoring;

import java.util.HashSet;
import java.util.Set;

public class DescriptionTextUniquefier {

	private Set<String> strings = new HashSet<>();

	public String getUniqueDescription(String junitSafeString) {
		while (strings.contains(junitSafeString)) {
			junitSafeString = junitSafeString + '\u200B'; // zero-width-space
		}
		strings.add(junitSafeString);
		return junitSafeString;
	}

}

package de.codecentric.jbehave.junit.monitoring;

import java.util.HashSet;
import java.util.Set;

public class DescriptionTextUniquefier {

	private Set<String> uniqueDescriptions = new HashSet<>();

	public String getUniqueDescription(String junitSafeString) {
		String uniqueDescription = junitSafeString;
		while (uniqueDescriptions.contains(uniqueDescription)) {
			uniqueDescription += '\u200B'; // zero-width-space
		}
		uniqueDescriptions.add(uniqueDescription);
		return uniqueDescription;
	}

}

Refactor DescriptionTextUniquefier