Eclipse — Testng references non-existing project X

2020-02-05 02:36发布

When trying to run a test as a TestNG suite, I would get a very cryptic error message saying that TestNG can't launch because it references a non-existant project. I think my project does exist, I see it in the package explorer!

9条回答
太酷不给撩
2楼-- · 2020-02-05 03:03

It doesn't have to be a Java Project, it could be a Maven one as well. There could be a reference problem with the oldest version of the project. Please try deleting the oldest version from your Eclipse workspace, and then change your reference point.

查看更多
Emotional °昔
3楼-- · 2020-02-05 03:07

I know this is an old post, but I hit this recently when I moved to using a MacBook Pro.

When I created a new Eclipse workspace and loaded all of my projects from the SCM, I got these Ant failures due to referencing an non-existing project.

The solution was not easy to discover, but the solution is simple: Change your Ant run configuration's JRE to run in the same JRE as the workspace.

You DO NOT need to change your build projects to Java projects.

查看更多
▲ chillily
4楼-- · 2020-02-05 03:10

If its an existing project, you must have classpath and project file in project root folder to make it java project.

Sample:

<!--classpath -->
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
    <attributes>
        <attribute name="optional" value="true"/>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
    <attributes>
        <attribute name="optional" value="true"/>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
    <attributes>
        <attribute name="maven.pomderived" value="true"/>
    </attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>

<!-- .project  -->
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>testProject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
    <buildCommand>
        <name>org.eclipse.jdt.core.javabuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
    <buildCommand>
        <name>org.eclipse.m2e.core.maven2Builder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>
<natures>
    <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
    <nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>

查看更多
We Are One
5楼-- · 2020-02-05 03:13

In my case the run shortcut was referencing an old project.

Simply right clicking on the folder of the project I was trying to run and selecting my java class fixed the problem.

After that pressing the run button started working again.

查看更多
Lonely孤独者°
6楼-- · 2020-02-05 03:15

This issue will manifest for you if you have a test class in a current project that you are trying to run that matches a test class from the project that you either closed or deleted and had previously run unit tests against.

Chances are you have a test case from this deleted / missing or closed project. Eclipse will hide the launch configurations of deleted and closed projects but still attempts to use them when you do the 'right click on class' -> 'run-as' way to invoke a unit test.

The solution here is to unhide the problem launch configuration so you can delete it or modify it to conform to the current project.

Unhide the launch configurations of deleted and closed projects:

This is done via the dropdown menu path -> Eclipse -> Preferences -> "Run/Debug" -> Launching -> "Launch Configurations" In the "Launch Configurations" screen find the "launch configuration filters" section and uncheck the top 2 checkboxes: - "Filter configurations in closed projects" - "Filter configurations in deleted or missing projects" click the "Apply and close" button and close the popup screen.

Edit / delete the problem configuration:

open the Run -> "Run configurations" from the dropdown menu. On the left find and select the (no longer hidden) run configuration. In this configuration you can either update the project references to the current project or you can delete the configuration altogether. If you delete the run configuration eclipse will create a new one from scratch with the correct project settings when you attempt to "run as" on the current class.

查看更多
成全新的幸福
7楼-- · 2020-02-05 03:26

I have faced the same problem while I was working with raspbian OS for raspberry pi. The problem was the java project was referencing to one of my previous project.

I resolved this problem by doing following steps.

  1. Go to Project->properties
  2. In properties window's left pane select "Run/Debug Settings".
  3. Select "Configure" and click "edit"
  4. In tab "Main" replace Project to your current project.
  5. Select "Main class" by clicking on search button(it will be your class name).
  6. Now hit OK.
查看更多
登录 后发表回答