1/*
2 * Copyright (C) 2010 The Android Open Source Project
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
17package android.test.suitebuilder;
18
19import java.util.List;
20
21import junit.framework.TestCase;
22
23/**
24 * Unit tests for {@link TestGrouping}
25 */
26public class TestGroupingTest extends TestCase {
27
28    private TestGrouping mGrouping;
29
30    @Override
31    protected void setUp() throws Exception {
32        super.setUp();
33        mGrouping = new TestGrouping(TestGrouping.SORT_BY_SIMPLE_NAME, getClass().getClassLoader());
34    }
35
36    /**
37     * Verifies that TestCases with no public constructor are not loaded.
38     * Relies on fixture classes in android.test.suitebuilder.examples.constructor
39     */
40    public void testGetTests_noPublicConstructor() {
41        mGrouping.addPackagesRecursive("android.test.suitebuilder.examples.constructor");
42        List<TestMethod> tests = mGrouping.getTests();
43        // only the PublicConstructorTest's test method should be present
44        assertEquals(1, tests.size());
45        assertEquals("testPublicConstructor", tests.get(0).getName());
46    }
47}
48