Add a test method to an existing test case by highlighting the method name in Eclipse

Not sure if this is possible, but it will save me a lot of time if that is the case. When I create a Junit4 test case in Eclise, I usually don’t include all the methods that I would like to test first, and later I would like to add unverified methods or new methods to the test case. I am currently doing this by typing new testing methods in an existing test case class. Is there a way to highlight the method name and create a test case if it does not exist or add an existing test case in Eclipse? Thanks in advance!

David

+3
source share
3 answers

. , , . , Eclipse " JUnit TestCase" , , " " - .

, , . , , .

, , , , !

+2

. , , . @Danny, , . , . - , , , , , , .

, ( ) , . , , .

+1

JUnit , , , JavaClassTest2, .

Off :

" ", . , . :

  • javadoc . , , , , , .
  • , 1 .

    @Test public void testRemoveHtmlTags() {
    String[] test = {
            "0. Null argument test failed.",
            "1. Case sensitive test failed.",
            "2. Case insensitive test failed." };
    
    
    try {
        StringUtils.removeHtmlTags(null);
        fail(test[0]);
    } catch (IllegalArgumentException iae) {}
    
    
    String input1 = "The quick Brown <b>Fox</b> Jumps&nbsp;Over The Lazy Dog. &gt;&lt;";
    String output1 = StringUtils.removeHtmlTags(input1);
    assertEquals(test[1], "The quick Brown Fox Jumps Over The Lazy Dog. ><", output1);
    
    
    String input2 = "The quick Brown <B>Fox</b> Jumps&nbsp;Over The Lazy Dog. &gt;&lt;";
    String output2 = StringUtils.removeHtmlTags(input2);
    assertEquals(test[2], "The quick Brown Fox Jumps Over The Lazy Dog. ><", output2);
    

    }

+1

Source: https://habr.com/ru/post/1749242/


All Articles