Java Simple Cipher Test Runner Not Working

I tried submitting my solution for the java/simple-cipher exercise last night and today, but both times the test runner failed with the error

An error occurred while running your tests. 
This might mean that there was an issue in our infrastructure, or it might mean that you have something in your code that's causing our systems to break.
Please check your code, and if nothing seems to be wrong, try running the tests again.

I then tried to submit the test with the default skeleton code and got the same error

Also I’m not sure if this is related but I can’t view the community solutions for the exercise either, the entire tab is just blank. This issue has been fixed

Thanks for reporting this!

We recently updated the tests for this exercise and I believe someone else also ran into the same issue: [simple-cipher] Fix outdated reference to SimpleCipherStepThreeTest by apetresc · Pull Request #2523 · exercism/java · GitHub

I ran the java-test-runner manually on the sample implementation and this is the error that is happening:

Exception in thread "main" java.lang.IllegalArgumentException: Multiple entries with same key: TestSource[packageName=, className=SimpleCipherTest, methodName=cipherCanEncode]=@Test
public void cipherCanEncode() {
    String plainText = "aaaaaaaaaa";
    String cipherText = "abcdefghij";
    assertThat(cipherWithDefaultKey.encode(plainText)).isEqualTo(cipherText);
} and TestSource[packageName=, className=SimpleCipherTest, methodName=cipherCanEncode]=/**
 * Here we take advantage of the fact that plaintext of "aaa..." doesn't output the key. This is a critical
 * problem with shift ciphers, some characters will always output the key verbatim.
 */
@Test
public void cipherCanEncode() {
    String plainText = "aaaaaaaaaa";
    String cipherText = cipherWithDefaultKey.getKey().substring(0, 10);
    assertThat(cipherWithDefaultKey.encode(plainText)).isEqualTo(cipherText);
}
	at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:210)
	at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:204)
	at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:146)
	at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:109)
	at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:389)
	at com.exercism.junit.JUnitTestParser.buildTestCodeMap(JUnitTestParser.java:51)
	at com.exercism.TestRunner.run(TestRunner.java:57)
	at com.exercism.TestRunner.main(TestRunner.java:40)

So it turns out the test runner cannot handle nested test classes that well, since the two methods it mentions are defined in separate nested classes.

I created an issue for it here: Tests defined in nested classes result in an error · Issue #69 · exercism/java-test-runner · GitHub.

I’m not sure I have the time to work on this soon though. @Beatzoid would you be up for it to try and fix this bug?

I was able to spend a little time seeing if this bug is easy to fix, and it looks like it’s going to take some effort to get nested test classes properly supported in the test runner. It’s definitely something I’d like to get fixed at some point, but until then I think the best course of action is not to use nested test classes on the Java track for now.

This means that the test cases for the exercise have to be updated, for which I created the following issue: Remove nested test classes from practice exercise `simple-cipher` · Issue #2538 · exercism/java · GitHub

@Beatzoid you are still welcome to have a stab at fixing the bug in the test runner if you’re up for it, but since it might require some investigation I can imagine that it’s a bit too much to start out with. Would you be willing to pick up the above issue to update the exercise tests instead?

1 Like

Thanks @sanderploegsma. I’ve asked @ErikSchierboom to take a look next week :slight_smile:

I don’t think this requires me actually. This is something a community PR could just as well do. E.g. by @Beatzoid or @sanderploegsma