0
import org.junit.Test;
import static org.junit.Assert.*;

public class TestPalindrome {
    // You must use this palindrome, and not instantiate
    // new Palindromes, or the autograder might be upset.
    static Palindrome palindrome = new Palindrome();

    @Test
    public void testWordToDeque() {
        Deque d = palindrome.wordToDeque("persiflage");
        String actual = "";
        for (int i = 0; i < "persiflage".length(); i++) {
            actual += d.removeFirst();
        }
        assertEquals("persiflage", actual);
    } 
}

public class Palindrome{

    public Deque<Character> wordToDeque(String word){
        ArrayDeque<Character> c = new ArrayDeque(); 
        for (char d : word.toCharArray()){
            c.addLast(d);
        }

        return c; 
    }
}

The method wordToDeque can technically have anything in it (e.g. return null), but it still just gives me "no main error found." it's a little bit perplexing. The compiler recognizes junit as I've added it to my environment variables. Does anyone know why this is happening?

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Makdessi
  • 3
  • 2

1 Answers1

0
  1. If you are using some build system like maven/gradle, running test goal should run your tests.
  2. If you are compiling using javac, you can use JUnit console launcher. See JUnit site for more details.
Dakshinamurthy Karra
  • 5,353
  • 1
  • 17
  • 28