自动发电机组测试

发布于 2024-08-19 06:01:50 字数 420 浏览 1 评论 0原文

我有一个 Web 工具,当查询时,它会根据 URL 中的参数返回生成的 Java 类。

我们从网络服务器检索的类每天都会变化,我们需要确保它们仍然可以处理已知的输入。

请注意,这些类不会测试 Web 服务器,它们在本地运行并将 xml 转换为自定义格式。我没有测试网络服务器。

然后,必须将这些类放置在特定的包结构中,针对一组已知的输入数据进行编译和运行,并与已知的输出数据进行比较。

我想每天晚上自动执行此操作,以确保生成的类是正确的。

实现这一目标的最佳方法是什么?

具体来说,最好的方法是什么:

  1. 从网络服务器检索代码并将其放入文件中
  2. 编译代码然后调用它

我确信 junit 和 ant 的混合将能够实现这一目标,但是有标准的解决方案/方法吗为了这?

I have a web tool which when queried returns generated Java classes based upon the arguments in the URL.

The classes we retrieve from the webserver change daily and we need to ensure that they still can process known inputs.

Note these classes do not test the webserver, they run locally and transform xml into a custom format. I am not testing the webserver.

These classes must then be placed in specific package structure compiled and run against a known set of input data and compared against known output data.

I would like to do this automatically each night to make sure that the generated classes are correct.

What is the best way to achieve this?

Specifically whats the best way to:

  1. retrieve the code from a webserver and place it in a file
  2. compile the code and then call it

I'm sure a mix of junit and ant will be able to achieve this but is there and standard solution / approach for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

素衣风尘叹 2024-08-26 06:01:50

首先,回答你的问题:不,我不认为有一个标准的方法。这听起来像是一种非常不寻常的情况;-)

鉴于此,我要做的就是编写 JUnit 测试来全部调用类 GeneratedCode,然后,下载代码后,将该类重命名为GenerateCode,编译并运行单元测试。

First up, to answer your question: No, I do not think that there is a standard approach for this. This sounds like quite an unusual situation ;-)

Given that, what I would do is to write your JUnit tests to all call a class GeneratedCode, and then, once you download the code, rename the class to GeneratedCode, compile, and run your unit tests.

久夏青 2024-08-26 06:01:50

您与持续集成有相同的目标;-)

对于这个简单的任务来说可能有点矫枉过正,但这是获取某些内容、编译某些内容并定期测试某些内容的标准方法。

例如,您可以尝试 hudson

You have the same goal as continuous integration ;-)

Maybe a bit overkill for this simple task, but this is the standard way to get something, compile something and test something regularly.

E.g. you could try hudson.

无名指的心愿 2024-08-26 06:01:50

您应该为您的 Web 服务创建一个“模拟”界面,该界面 (a) 的行为方式相同并且 (b) 返回已知的答案。

然后,您应该使用实时 Web 服务进行一些其他集成测试,由人员查看结果并确定它们是否有效。

You should be creating a "mock" interface for your web service that (a) behaves the same way and (b) returns a known answer.

You should then do some other integration testing with the live web service where a person looks at the results and decides if they worked.

So要识趣 2024-08-26 06:01:50

您只能在将生成的类发布到 Web 服务上之后才对其进行测试吗?你没有办法在生成期间或生成之后进行测试吗?

如果生成的代码不太复杂,一种想法是通过 GroovyClassLoader 加载它并针对它运行测试。有关示例,请参阅此页面

Can you only test the generated classes after they were published on the webservice ? You have no way to test during or just after the generation ?

One idea, if the generated code isn't to complex, is to load it via the GroovyClassLoader and to run your tests against it. See this page for examples.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文