ルビーのみを使用して同じテストを実行すると、成功します。JRuby を使用して Java から同じテストを実行しようとすると、「watir-webdriver」、「rubygems」などの必要なファイルが見つかりません。
Ruby ファイル:
require "rubygems"
require "watir-webdriver"
puts "Hello!!! test finished"
エラー トレース:
LoadError: no such file to load -- rubygems
require at org/jruby/RubyKernel.java:1054
(root) at /home/Oras/workspace/OptifyTestSuiteRuby/automation-watir/tes.rb:2
Exception in thread "main" org.jruby.embed.EvalFailedException: (LoadError) no such file to load -- rubygems
at org.jruby.embed.internal.EmbedEvalUnitImpl.run(EmbedEvalUnitImpl.java:133)
at org.jruby.embed.ScriptingContainer.runUnit(ScriptingContainer.java:1264)
at org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1309)
at OptifyTest.com.Main.<init>(Main.java:18)
at OptifyTest.com.Main.main(Main.java:22)
Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- rubygems
at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1054)
at RUBY.(root)(/home/Oras/workspace/OptifyTestSuiteRuby/automation-watir/tes.rb:2)
Java ファイル:
import java.util.ArrayList;
import java.util.List;
import org.jruby.embed.PathType;
import org.jruby.embed.ScriptingContainer;
public class Main {
private final static String jrubyhome = "/home/Oras/workspace/OptifyTestSuiteRuby/automation- watir";
private final String filename = jrubyhome + "/tes.rb";
private Main() {
ScriptingContainer container = new ScriptingContainer();
List<String> loadPaths = new ArrayList();
loadPaths.add(jrubyhome);
container.setLoadPaths(loadPaths);
container.runScriptlet(PathType.ABSOLUTE, filename);
}
public static void main(String[] args) {
new Main();
}
}