Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   *
   *              C E D A R
   *          S O L U T I O N S       "Software done right."
   *           S O F T W A R E
   *
   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
   *
   * Copyright (c) 2013 Kenneth J. Pronovici.
  * All rights reserved.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the Apache License, Version 2.0.
  * See LICENSE for more information about the licensing terms.
  *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  * Author   : Kenneth J. Pronovici <pronovic@ieee.org>
  * Language : Java 6
  * Project  : Common Java Functionality
  *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 package com.cedarsolutions.junit.gwt;
 
 
 
JUnit 4.5 test runner used for running stubbed GWT client tests.

This test runner configures JUnit 4.5 to use a different classloader that stubs out certain GWT operations like GWT.create(). This way, unit tests that are annotated as RunWith(GwtStubbedTestRunner.class) don't need to run real GWT client tests (i.e. extending GWTTestCase). Instead, they can validate using mocks. This is a lot faster and easier, especially for MVP4G presenters and event handlers. You will probably need to write true client tests for views and other client-side widgets.

This class was derived in part from source code in gwt-test-utils. See README.credits for more information.

Author(s):
Kenneth J. Pronovici <pronovic@ieee.org>
 
 public class GwtStubbedTestRunner extends Runner implements FilterableSortable {
 
     private static final String JUNIT4_TEST_RUNNER = BlockJUnit4ClassRunner.class.getCanonicalName();
 
     private final Runner runner;
 
     public GwtStubbedTestRunner(Class<?> clazzthrows Exception {
         Class<?> runnerClass = GwtClassLoader.get().loadClass();
         Constructor<?> constructor = runnerClass.getConstructor(Class.class);
          = (Runnerconstructor.newInstance(GwtClassLoader.get().loadClass(clazz.getCanonicalName()));
     }
 
     @Override
     public void run(RunNotifier notifier) {
         .run(notifier);
     }
 
     @Override
     public int testCount() {
         return .testCount();
     }
 
     @Override
     public Description getDescription() {
         return .getDescription();
     }
 
     @Override
     public void filter(Filter filterthrows NoTestsRemainException {
         if (Filterable.class.isInstance()) {
             ((Filterable).filter(filter);
         }
     }
 
     @Override
     public void sort(Sorter sorter) {
         if (Sortable.class.isInstance()) {
             ((Sortable).sort(sorter);
         }
     }
New to GrepCode? Check out our FAQ X