简体   繁体   中英

Sharing JUnit tests between client and server

Hello fantastic people!

I am developing a java module which will be used both on the server, and on the client (GWT).

I want to write a library of unit tests, and then simply create wrappers to run the tests on the client and on the server. This way, I can gurentee that the code behaves correctly on both, without having to write separate unit tests for each.

However, I see that there is no native support for JUnit in GWT and that GWTTestCase has to be used.

I was hoping someone might have a clever solution that would allow me to do this.

Thanks,

Casey

If your GWTTestCase returns null from getModuleName() , it'll be run as a simple JUnit test. The idea is thus to have 2 classes, one extending the other and overriding getModuleName() .

FYI, this is the exact technique used by GWT itself in its unit-tests; for instance for RequestFactory or AutoBeans; for instance RequestFactoryTest which extends GWTTestCase and RequestFactoryJreTest which extends RequestFactoryTest , overriding getModuleName() to return null as well as the way the tests are setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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