-2

I'm trying to work on a homework assignment. We're given a bunch of files, and the first step in the instructions says that I need to run one of the Java files that we're given, which acts as a testing file.

Here is the file,

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class ListBoundedIntSetTestSuiteRunner {

  public static void main (final String[] args) {
    final Result result =
      JUnitCore.runClasses(ListBoundedIntSetTestSuite.class);
    for (final Failure failure : result.getFailures()) {
      System.out.println(failure.toString());
    }
    if (result.wasSuccessful()) {
      System.out.println("Congratulations: all tests passed!");
    }
    final int runs      = result.getRunCount();
    final int failures  = result.getFailureCount();
    final int ignores   = result.getIgnoreCount();
    final int successes = runs - failures;
    System.out.printf("Tests run:     %d%n", runs);
    if (ignores > 0) {
      System.out.printf("Tests ignored: %d%n", ignores);
    }
    System.out.printf("Tests passed:  %d%n", successes);
    if (failures > 0) {
      System.out.printf("Tests failed:  %d%n", failures);
    }
  }
}

The instructions literally say that I just have to open this in Eclipse and click run and it should work. I have seen this work on a friend's computer as well. I have not changed any files or done anything at all.

When I try to run this file, I get the error "Selection does not contain a main type".

I have cleaned the workspace, uninstalled and reinstalled Eclipse, uninstalled and reinstalled Java but nothing seems to work.

Human Cyborg Relations
  • 1,202
  • 5
  • 27
  • 52
  • Hope [this](http://stackoverflow.com/questions/16225177/error-selection-does-not-contain-a-main-type) will help you. – jack jay Feb 04 '17 at 23:15

1 Answers1

0

Remove the final from final String[] args, it's preventing your main method from being recognised as a main method.

Emily
  • 1,030
  • 1
  • 12
  • 20