gwt dev模式运行时的服务器端测试用例

时间:2022-04-12 15:46:03

So I have this (a bit) weird idea - there is The System being developed which is communicating with outside world through various services, but it's entirely server-side and is deployed as a single war. I'd like to write a basic UI (dev/debug-grade, not intended for production) for it. The main goals:

所以我有这个(有点)奇怪的想法 - 正在开发的系统通过各种服务与外界进行通信,但它完全是服务器端,并且作为单一战争部署。我想为它编写一个基本的UI(开发/调试级,不适合生产)。主要目标:

  • Avoid calling The System services, instead call methods directly on the java objects
  • 避免调用System服务,而是直接在java对象上调用方法

  • Use GWT
  • Must work both from test-cases (testng) and as a deployed war on tomcat (preferably both in development and production gwt modes)
  • 必须同时使用测试用例(testng)和tomcat上的部署战争(最好是在开发和生产gwt模式下)

  • keep it seperate, limit changes to The System
  • 保持独立,限制对系统的更改

So... How to do this with gwt? When deploying to tomcat, I'd put both into the same war. (because different wars have different classloaders). When running testcases (integration, they use db and everything) I'd start embedded jetty during initialization and register new gwt servlet.

那么......如何用gwt做到这一点?当部署到tomcat时,我会把两者都放在同一个战争中。 (因为不同的战争有不同的类加载器)。当运行测试用例(集成,他们使用db和所有东西)时,我会在初始化期间启动嵌入式jetty并注册新的gwt servlet。

Ok, this sounds doable. But what about dev mode? I'd like to be able to start regular dev mode which would allow to

好的,这听起来可行。但是dev模式怎么样?我希望能够启动常规开发模式,这将允许

  • modify UI code (it would obviously do), and
  • 修改UI代码(显然会这样做),和

  • modify serverside code (which I would normally achieve with jrebel) - but how to run testcases in this case? I will not rewrite them for sure.
  • 修改服务器端代码(我通常用jrebel实现) - 但是在这种情况下如何运行测试用例?我肯定不会重写它们。

Dropping the idea to run UI and The System in the same jvm would help and would allow nice separation, but would also force me to write some pointless RPC/RMI/something stuff.

放弃在同一个jvm中运行UI和系统的想法将有所帮助,并允许很好的分离,但也会迫使我写一些毫无意义的RPC / RMI /东西。

Any insights on how to approach this?

有关如何处理此问题的任何见解?

Btw - this is just an after-hours project, so crazy-I-would-never-do-that-in-a-real-system ideas are welcome.

顺便说一句 - 这只是一个非工作时间的项目,非常疯狂 - 我永远不会这样做,真正的系统理念是值得欢迎的。

1 个解决方案

#1


0  

Running the backend (Tomcat,Jetty, etc) and the frontend (GWT dev mode) in separate JVM works just fine. That's actually now more or less the recommended approach (especially if you want to use SuperDevMode at some point).

在单独的JVM中运行后端(Tomcat,Jetty等)和前端(GWT dev模式)工作正常。实际上现在或多或少是推荐的方法(特别是如果你想在某些时候使用SuperDevMode)。

Here is my development strategy using eclipse:

这是我使用eclipse的开发策略:

  1. Start the backend server using WTP and Jetty in debug mode (JRebel for hot swapping classes when I change something on the backend).
  2. 在调试模式下使用WTP和Jetty启动后端服务器(当我在后端更改某些内容时,JRebel用于热交换类)。

  3. Start GWT dev mode
  4. 启动GWT开发模式

  5. Open GWT app in browser
  6. 在浏览器中打开GWT应用程序

This way when I change something in the GWT part I just have to refresh the browser and I see the changes in the UI.
JRebel takes care of all changes in the backend part.

这样当我在GWT部分中更改某些内容时,我只需要刷新浏览器,我就会看到UI中的更改。 JRebel负责后端部分的所有更改。

Communication between frontend and backend is done the same way as it would have been done in production mode (RequestFactory, RPC or RequestBuilder).

前端和后端之间的通信与在生产模式(RequestFactory,RPC或RequestBuilder)中完成的方式相同。

#1


0  

Running the backend (Tomcat,Jetty, etc) and the frontend (GWT dev mode) in separate JVM works just fine. That's actually now more or less the recommended approach (especially if you want to use SuperDevMode at some point).

在单独的JVM中运行后端(Tomcat,Jetty等)和前端(GWT dev模式)工作正常。实际上现在或多或少是推荐的方法(特别是如果你想在某些时候使用SuperDevMode)。

Here is my development strategy using eclipse:

这是我使用eclipse的开发策略:

  1. Start the backend server using WTP and Jetty in debug mode (JRebel for hot swapping classes when I change something on the backend).
  2. 在调试模式下使用WTP和Jetty启动后端服务器(当我在后端更改某些内容时,JRebel用于热交换类)。

  3. Start GWT dev mode
  4. 启动GWT开发模式

  5. Open GWT app in browser
  6. 在浏览器中打开GWT应用程序

This way when I change something in the GWT part I just have to refresh the browser and I see the changes in the UI.
JRebel takes care of all changes in the backend part.

这样当我在GWT部分中更改某些内容时,我只需要刷新浏览器,我就会看到UI中的更改。 JRebel负责后端部分的所有更改。

Communication between frontend and backend is done the same way as it would have been done in production mode (RequestFactory, RPC or RequestBuilder).

前端和后端之间的通信与在生产模式(RequestFactory,RPC或RequestBuilder)中完成的方式相同。