1

我们致力于改进 Apache Velocity Engine 源代码中的 smth',但我们在构建它时遇到了它的测试问题。

我们从github 上的Apache/Velocity克隆了源代码。

然后我们尝试构建引擎,但我们得到了这个错误。

Failed tests:   testVelTools66(org.apache.velocity.test.issues.VelTools66TestCase): Method object does not match! expected:<public abstract java.lang.String org.apache.velocity.test.issues.VelTools66TestCase$TestInterface.getTestValue()> but was:<public java.lang.String org.apache.velocity.test.issues.VelTools66TestCase$TestObject.getTestValue()>
  testResourceLoaderInstance(org.apache.velocity.test.ResourceLoaderInstanceTestCase): Processed template did not match expected output

Tests in error: 
  testClasspathResource(org.apache.velocity.test.ClasspathResourceTestCase): Unable to find resource 'template/test1.vm'
  testContextSafety(org.apache.velocity.test.ContextSafetyTestCase): Unable to find resource 'context_safety.vm'
  testHighByteChinese2(org.apache.velocity.test.EncodingTestCase): Unable to find resource 'encodingtest3.vm'
  testChineseEncoding(org.apache.velocity.test.EncodingTestCase): Unable to find resource 'encodingtest.vm'
  testHighByteChinese(org.apache.velocity.test.EncodingTestCase): Unable to find resource 'encodingtest2.vm'
  testRussian(org.apache.velocity.test.EncodingTestCase): Unable to find resource 'encodingtest_KOI8-R.vm'
  testMultiLoader(org.apache.velocity.test.MultiLoaderTestCase): Unable to find resource 'template/test1.vm'
  testSharedRepo(org.apache.velocity.test.StringResourceLoaderRepositoryTestCase): Unable to find resource 'foo'
  testAlternateStaticRepo(org.apache.velocity.test.StringResourceLoaderRepositoryTestCase): Unable to find resource 'foo'
  Arithmetic(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'arithmetic.vm'
  Array(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'array.vm'
  Block(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'block.vm'
  Comment(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'comment.vm'
  Equality(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'equality.vm'
  Escape(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'escape.vm'
  Foreach-array(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-array.vm'
  Foreach-method(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-method.vm'
  Foreach-variable(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-variable.vm'
  Formal(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'formal.vm'
  If(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'if.vm'
  Logical(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'logical.vm'
  Loop(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'loop.vm'
  Method(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'method.vm'
  Quotes(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'quotes.vm'
  Sample(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'sample.vm'
  Shorthand(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'shorthand.vm'
  Test(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'test.vm'
  Diabolical(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'diabolical.vm'
  Pedantic(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'pedantic.vm'
  Subclass(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'subclass.vm'
  Foreach-map(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-map.vm'
  Include(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'include.vm'
  Escape2(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'escape2.vm'
  Parse(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'parse.vm'
  Velocimacro(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'velocimacro.vm'
  Reference(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'reference.vm'
  Interpolation(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'interpolation.vm'
  Vm_test1(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'vm_test1.vm'
  Map(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'map.vm'
  Literal(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'literal.vm'
  Ifstatement(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'ifstatement.vm'
  Math(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'math.vm'
  Range(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'range.vm'
  Get(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'get.vm'
  Velocimacro2(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'velocimacro2.vm'
  Foreach-type(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-type.vm'
  Foreach-introspect(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-introspect.vm'
  Settest(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'settest.vm'
  Newline(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'newline.vm'
  Logical2(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'logical2.vm'
  String(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'string.vm'
  Stop1(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'stop1.vm'
  Stop2(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'stop2.vm'
  Foreach-null-list(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'foreach-null-list.vm'
  Curly-directive(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'curly-directive.vm'
  Comment-eof(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'comment-eof.vm'
  Commas(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'commas.vm'
  Stop3(org.apache.velocity.test.TemplateTestCase): Unable to find resource 'stop3.vm'

Tests run: 444, Failures: 2, Errors: 58, Skipped: 0

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project velocity: There are test failures.

Please refer to C:\apache\velocity-engine\target\surefire-reports for the individual test results.
-> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

正如我们所认为的,通常此消息意味着失败的测试无法找到模板资源。

注意:这些错误发生在我们没有任何编辑的情况下。如果您克隆了 prev 中的 1.7.x 引擎。URL 你会得到同样的错误。

我希望有人能解决这个问题。谢谢。

4

1 回答 1

0

似乎是因为TemplateTestBase.java

public static final String TEST_COMPARE_DIR = "@test.dir@";
public static final String TEST_RESULT_DIR = "@build.test@";

build.properties

test.dir= ${velocity.dir}/test

build.test= ${build.dir}/test

因此,如果您使用 ant 运行测试,则不必更改TEST_COMPARE_DIRand TEST_RESULT_DIR,否则您可以将这些字符串常量相应地更改为绝对路径。

于 2017-08-05T16:33:39.537 回答