0

I have this class, but eclipse does not recognize it as a test class, so I can not run it as a Junit test, I am using TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use,

import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;


public class ApplicationServiceImplTest {

    @Mock
    ApplicationDao dao;

    @InjectMocks
    ApplicationMutatorServiceImpl applicationMutatorServiceImpl;

    @BeforeClass
    public void setUp(){
        MockitoAnnotations.initMocks(this);
    }

    @Test
    public void testSave() throws Exception {

        Application application = new Application();
        applicationMutatorServiceImpl.save(application);
        System.out.println (application);

    }
}

in my pom.xml

 <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
juherr
  • 5,640
  • 1
  • 21
  • 63
  • Shouldn't there be a tearDown() in your class? – SomeDude Feb 20 '16 at 14:05
  • `JUnit != TestNG` How could you possibly think that Eclipse recognizes your _TestNG_ test classes as _JUnit_ test classes? Well ... I am not familiar with TestNG, but maybe the [docs](http://testng.org/doc/eclipse.html) help. – Seelenvirtuose Feb 20 '16 at 14:06
  • 1
    You mean that 'Eclipse does not recognize it as a JUnit test class'? This is likely the proper description of the problem. Have you checked whether your testing framework is supported by default in eclipse? If not, use JUnit – ernest_k Feb 20 '16 at 14:06

1 Answers1

2

Check if you have TestNG plugin installed. http://singinginthesunlight.blogspot.in/2016/02/testng-for-dummies.html

Otherwise you can run it through Maven