diff --git a/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java b/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
index 251af0d947ca023c628748cd51407c8904be1741..0b239c2a8f6a65a8dd3d6cc422bbeb6baddf206f 100644
--- a/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
+++ b/src/main/java/uk/ac/rhul/cs/javatester/CodeTester.java
@@ -450,7 +450,7 @@ public class CodeTester {
      *
      * @param klass the class the method belongs to
      * @param isStatic true if the method should be static
-     * @param returnType class of return type
+     * @param returnType class of return type or null if we don't care
      * @param methodName name of method
      * @param params the class of the method arguments
      * @throws failed test or no such method exception if not found
@@ -465,8 +465,10 @@ public class CodeTester {
 
         String staticString = isStatic ? "static " : "";
         String className = getClassString(klass);
+        String returnTypeString
+            = returnType == null ? "<return type>" : getClassString(returnType);
         String methodSig =
-            getClassString(returnType) + " " +
+            returnTypeString + " " +
             methodName + "(" + getClassParamsString(params) + ") ";
 
         String baseErr =
@@ -477,7 +479,7 @@ public class CodeTester {
         try {
             Method m = invasiveGetMethod(klass, methodName, params);
 
-            if (!m.getReturnType().equals(returnType)) {
+            if (returnType != null && !m.getReturnType().equals(returnType)) {
                 throw new BaseTester.FailedTestException(
                     baseErr + "\n\n" +
                     "A similar method was found, but the return types do not match."