- This topic has 3 replies, 2 voices, and was last updated 13 years, 12 months ago by support-neeraj.
-
AuthorPosts
-
madhockeydadMemberHi
It is possible to select New -> Web Project and then enter a name for the web project and on that wizard is a section with a check box – “Add Maven Support”. If checked this will create a standard MyEclipse web project with a pom.xml at the root level. The structure of the project will not be the Maven conventional structure but rather then MyEclipse structure with the proper changes to the pom.xml.
My question is using this approach where do the Unit Tests go (there is no directory named “tests” created) so that they will be executed automatically as would happen with the standard (conventional) maven structure?
If the tooling is going to support adding maven to a standard MyEclipse web project it seems like it should include the directories and/or mappings for the unit tests as well.
David
support-neerajMemberHi David,
Please find the steps below. With this you can create a folder to store all your test cases. The changes in the pom.xml file will enable the test cases to be executed automatically as it happens in a conventional maven project.1) Add a new source folder to the project (say tests) that will contain all the tests. You can do this using the project right click context menu->Build Path->New Source folder.
2) In the pom.xml file copy the following junit dependeny.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
3) Add the “testSourceDirectory” element under the <build> element as shown below
<build>
…
<testSourceDirectory>${basedir}/tests</testSourceDirectory>
</build>
madhockeydadMemberHi
In my WAR project, the unit tests work when I add the JUNIT dependency with a scope of compile but not for a scope of test!!! If I use the scope of test I get the following exception (which shows it is not using JUnit with a scope of test):
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project DavidMultiWAR: Compilation failure: Compilation failure:
C:\Documents and Settings\ditdla\Workspaces\MyEclipse-8.6\DavidMultiWAR\src\test\java\david\test\DummyClassTest.java:[4,22] package junit.framework does not existC:\Documents and Settings\ditdla\Workspaces\MyEclipse-8.6\DavidMultiWAR\src\test\java\david\test\DummyClassTest.java:[6,36] cannot find symbol
symbol: class TestCase
public class DummyClassTest extends TestCase {
support-neerajMemberHi David,
Can you please check the “Maven classpath container” (Maven Dependencies) in your project and verify if it has the Junit jar present in it. You can do this just by expanding the Maven Dependencies container in your project. If the jar is not present, please make some changes in the pom.xml file and save it. This will download the jar into the Maven classpath container. This should fix the above issue. -
AuthorPosts