2

Tycho を使用して Eclipse RCP アプリケーションの jUnit テストを実行しようとしています。

そのために、Run as > jUnit-Test をクリックすると実行される単純な jUnit テストを作成しました。しかし、mvn test で実行したい場合、jUnit が見つかりません。

jUnitをBuild-Pathに追加する必要があることをインターネットで読みました。-> 私はすでにそれをしました。さらに、Manifest.mf ファイルに jUnit を require-bundle として追加する必要があることを読みました。しかし、問題があります!! エラーが表示されます: バンドル 'org.junit' を解決できません。

私の MANIFEST.MF ファイルは次のようになります。

    Manifest-Version: 1.0
    Bundle-ManifestVersion: 2
    Bundle-Name: Tests
    Bundle-SymbolicName: myPackageName
    Bundle-Version: 1.0.0.qualifier
    Bundle-Vendor: myCompany
    Fragment-Host: thePackageWhereTestesPluginIs
    Bundle-RequiredExecutionEnvironment: JavaSE-1.6
    Require-Bundle: org.junit

私の間違いはどこですか?org.junit4 を使用しても解決できません...

ありがとうございました!

アップデート:

今ではrequire-bundleの代わりに使用しています:

    Import-package: org.junit4

(または org.junit、その動作は同じです)、manifest.mf ファイルで解決できます。しかし、実行すると次のエラーが表示されます: [ERROR] -> [Help 1] org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: org.osgi.framework.BundleException: Bundle myTestBundle cannot be解決済み 解決エラー: バンドル myTestBundle - 制約がありません: Import-Package: org.junit4; バージョン="0.0.0"

どうすればこれを解決できますか?

ありがとうございました!!

テストバンドルの私の pom ファイル:

<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">    <modelVersion>4.0.0</modelVersion>
<parent>
        <artifactId>myProject.tycho.master</artifactId>
        <groupId>myProject</groupId>
        <version>0.0.1-SNAPSHOT</version>
        <relativePath>../myProject.tycho.master/pom.xml</relativePath>
    </parent>
    <groupId>myProject</groupId>
    <artifactId>myProject.myTestBundle</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>eclipse-test-plugin</packaging>

<dependencies>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.8.1</version>
</dependency>
</dependencies>
</project>

親ポン:

    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<modelVersion>4.0.0</modelVersion>
<groupId>myProject</groupId>
<artifactId>myProject.tycho.master</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

<properties>
    <tycho.version>0.17.0</tycho.version>
</properties>

<modules>
    <module>../myProject.myTestBundle</module>

</modules>



<repositories>
    <!-- configure p2 repository to resolve against -->
    <repository>
        <id>Repository1</id>
        <layout>p2</layout>
        <url>url-to-a-p2-site-on-my-server</url>
    </repository>
</repositories>

<build>
    <plugins>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-maven-plugin</artifactId>
            <version>${tycho.version}</version>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>target-platform-configuration</artifactId>
            <version>${tycho.version}</version>
            <configuration>
                <resolver>p2</resolver>
                <pomDependencies>consider</pomDependencies>
                <target>
                    <artifact>
                        <groupId>myGroupId</groupId>
                        <artifactId>myGroupId.target</artifactId>
                        <classifier>targetPlatform</classifier>
                    </artifact>
                </target>
                <environments>
                    <environment>
                        <os>macosx</os>
                        <ws>cocoa</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>linux</os>
                        <ws>gtk</ws>
                        <arch>x86_64</arch>
                    </environment>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86</arch>
                    </environment>
                    <environment>
                        <os>win32</os>
                        <ws>win32</ws>
                        <arch>x86_64</arch>
                    </environment>
                </environments>
                <ignoreTychoRepositories>false</ignoreTychoRepositories>
            </configuration>
        </plugin>
    </plugins>
</build>
    </project>

更新: 問題を解決したと思います! p2 Update サイトに jUnit を追加したところ、エラーが発生しなくなりました。

4

1 に答える 1

1

jUnit を p2 Update サイトとして追加して問題を修正し、Manifest.mf で次のように使用しました。

Require-Bundle: org.junit; bundle-version = "4.11.0"
于 2013-04-17T10:29:27.940 に答える