简体   繁体   English

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

[英]server-side test cases while gwt dev mode is running

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. 我想为其编写一个基本的UI(dev / debug级,不用于生产)。 The main goals: 主要目标:

  • Avoid calling The System services, instead call methods directly on the java objects 避免调用系统服务,而是直接在java对象上调用方法
  • Use GWT 使用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? 那么...如何用gwt做到这一点? When deploying to tomcat, I'd put both into the same war. 当部署到tomcat时,我将两者置于同一场战争中。 (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. 在运行测试用例(集成时,它们使用db等)时,我将在初始化期间启动嵌入式码头并注册新的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 我希望能够启动常规开发模式,这将允许

  • 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? 修改服务器端代码(通常使用jrebel可以实现)-但是在这种情况下如何运行测试用例? I will not rewrite them for sure. 我不会肯定地重写它们。

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和System的想法会有所帮助,并且可以实现很好的分离,但是也会迫使我写一些毫无意义的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. 顺便说一句-这只是一个下班后的项目,因此,我绝对不会在一个真实的系统中疯狂的想法。

Running the backend (Tomcat,Jetty, etc) and the frontend (GWT dev mode) in separate JVM works just fine. 在单独的JVM中运行后端(Tomcat,Jetty等)和前端(GWT开发人员模式)就可以了。 That's actually now more or less the recommended approach (especially if you want to use SuperDevMode at some point). 现在实际上实际上是推荐的方法(特别是如果您想在某个时候使用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). 在调试模式下使用WTP和Jetty启动后端服务器(当我在后端更改某些内容时,JRebel用于热交换类)。
  2. Start GWT dev mode 启动GWT开发模式
  3. Open GWT app in browser 在浏览器中打开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. 这样,当我在GWT部分中更改某些内容时,只需要刷新浏览器,即可在UI中看到更改。
JRebel takes care of all changes in the backend part. JRebel负责后端部分的所有更改。

Communication between frontend and backend is done the same way as it would have been done in production mode ( RequestFactory , RPC or RequestBuilder ). 前端和后端之间的通信与在生产模式下( RequestFactoryRPCRequestBuilder )进行通信的方式相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM