facebook

MyEclipse 7.0M2, maven packaging=war, JUnit don’t execute

  1. MyEclipse IDE
  2.  > 
  3. Maven for MyEclipse (Maven4MyEclipse)
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #290370 Reply

    allenparslow
    Member

    In MyEclipse 7.0M2 I’m getting JUnit/TestNG problems (running with the plugins), with the default maven build configuration and <packaging>war</packaging>.

    Steps to recreate:
    Start with clean pom (<packaging>jar</packaging>) with just JUnit /or TestNG dependencies and a simple test-class in src/test/java. Import as maven project.

    Run mvn clean, then from MyEclipse menu select Project/Clean.
    Run JUnit/TestNG class. [executes sucessfully and the test class are output to target/test-classes] [also executes with mvn clean test].

    Remove project from MyEclipse. Delete all files in the project folder except /src and pom.xml, re-import maven project.

    Run mvn clean, then from MyEclipse menu select Project/Clean.
    Run JUnit/TestNG class which fails (ClassNotFoundException) and the test class are NOT output to target/test-classes (but still executes ok with mvn clean test).

    #290419 Reply

    Loyal Water
    Member

    allenparslow,
    I have asked someone from the dev team to look into this issue. He will get back to you with an update asap. Thank you for your patience.

    #290751 Reply

    allenparslow,

    I can’t reproduce what you see. I did the following:
    1. I created project using quickstart prototype.
    2. I used m2eclipse “General/Maven Projects…” import wizard.
    3. My workspace was set to Build Automatically but I tried removing that checkbox too.

    #290766 Reply

    allenparslow
    Member

    Step #1: Create this project structure:

    JUnitTest
    |-pom.xml
         |-src
        |-test
            |-java
                |-testing
                    |-SimpleJUnitTest.java
        |-main 
            |-java
            |-webapp 
                |-WEB-INF
                    |-web.xml

    pom.xml contents:

    <?xml version="1.0"?>
    <project>
        <modelVersion>4.0.0</modelVersion>
        <groupId>testing</groupId>
        <artifactId>Test</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        
        <packaging>war</packaging>
        
        <repositories>
            <repository>
                <id>maven2</id>
                <name>maven2</name>
                <url>http://repo1.maven.org/maven2/</url>
            </repository>
        </repositories>    
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>3.8</version>
            </dependency>
        </dependencies>
    </project>

    SimpleJUnitTest.java contents:

    package testing;
    
    import junit.framework.Assert;
    import junit.framework.TestCase;
    
    public class SimpleJUnitTest extends TestCase {
        public void testTest() {    
            Assert.assertEquals(1, 1);    
        }
    }

    Step #2: Enable importing of existing maven project
    MyEclipse menu Window/Preferences/”MyEclipse Enterprise Workbench”/Maven4MyEclipse/”Enable all m2eclipse features”=true

    Step #3: Import project with:
    MyEclilpse menu File/Import…/Maven Projects/

    Step #4: right click SimpleJUnitTest, choose run as…JUnit test

    #290767 Reply

    allenparslow
    Member

    If the class is put in src/main/java it runs just fine (it appears to be only test-cases in src/test/java).

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: MyEclipse 7.0M2, maven packaging=war, JUnit don’t execute

You must be logged in to post in the forum log in