• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Guava Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.common;
18 
19 import com.google.common.reflect.ClassPath;
20 import com.google.common.reflect.ClassPath.ClassInfo;
21 import com.google.gwt.junit.client.GWTTestCase;
22 import com.google.gwt.junit.tools.GWTTestSuite;
23 
24 import junit.framework.Test;
25 import junit.framework.TestCase;
26 
27 import java.io.IOException;
28 
29 /**
30  * Runs all _gwt tests. Grouping them into a suite is much faster than running each as a one-test
31  * "suite," as the per-suite setup is expensive.
32  */
33 public class GwtTestSuite extends TestCase {
suite()34   public static Test suite() throws IOException {
35     GWTTestSuite suite = new GWTTestSuite();
36     for (ClassInfo info
37         : ClassPath.from(GwtTestSuite.class.getClassLoader()).getTopLevelClasses()) {
38       if (info.getName().endsWith("_gwt")) {
39         Class<?> clazz = info.load();
40         // TODO(cpovirk): why does asSubclass() throw? Is it something about ClassLoaders?
41         @SuppressWarnings("unchecked")
42         Class<? extends GWTTestCase> cast = (Class<? extends GWTTestCase>) clazz;
43         suite.addTestSuite(cast);
44       }
45     }
46     return suite;
47   }
48 }
49