Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Follow the same procedure as described for in the Synapse-Services-Repository project:Developer Best Practices 

Use SafeHtml

Read this document on use of SafeHtml in GWT and adhere strictly to the contracts described. Apply true escaping methods to any user-generated value in the system.  

Testing

See the general Synapse testing philosophy on the Synapse-Services-Repository Developer Best Practices page.

Specifics For GWT Testing

  • Put all business logic into Presenters and make them JRE testable (aka JUnit). 
    • The philosophy of our infrastructure and this technique is described here
    • This means that Presenters can not deal with class instances that rely upon GWT.create(...) calls. For the rare case when this is necessary, create a GWTTestCase. Be aware that these tests take significant time to spin up.
  • To mock callbacks, such as with RPC services, use AsyncMockStubber's static methods. 

    Code Block
    languagejava
    // Example call onSuccess(..)
    AsyncMockStubber.callSuccessWith("Result Object").when(mockService).getSomething(eq("someInputParam"), any(AsyncCallback.class)); 
     
    // Example call onFailure(..)
    AsyncMockStubber.callFailureWith(new Throwable("error message")).when(mockService).getSomething(eq("someInputParam"), any(AsyncCallback.class));