FrameworkTestRunnerTests is the test for android.test.runner. The test
accesses various private APIs from the sdk library. Previously, that was
possible because depending on a java_sdk_library gave the implementation
lib of the java_sdk_library for linking. That will be changed after
I14cf217f21fd3534c920c3a6336cf2d14c02e60c where the stubs are by default
provided for linking.
Since this test actually uses some hidden APIs, work around the
restriction by explicitly depending on the impl library.
Bug: 157007292
Test: m FrameworkTestRunnerTests
Change-Id: I0792e9eb1c7c594a1609eb89b6694c1578c86e18
With b/150232615, we will need an explicit value set for the exported
flag when intent filters are present, as the default behavior is
changing for S+. This change adds the value reflecting the previous
default to the manifest.
Bug: 150232615
Test: TH
Change-Id: I041de56cfab67e2851751be65d26cfe80cdb9cb2
This change sets LOCAL_SDK_VERSION for all packages where
this is possible without breaking the build, and
LOCAL_PRIVATE_PLATFORM_APIS := true otherwise.
Setting one of these two will be made required soon, and this
is a change in preparation for that. Not setting LOCAL_SDK_VERSION
makes the app implicitly depend on the bootclasspath, which is
often not required. This change effectively makes depending on
private apis opt-in rather than opt-out.
Test: make relevant packages
Bug: 73535841
Change-Id: I4233b9091d9066c4fa69f3d24aaf367ea500f760
Statically including legacy-android-test leads to duplicate classes
which causes build time problems (with Proguard) and runtime problems on
older SDK versions. This change:
* Stops statically including legacy-android-test.
* Adds compile time dependencies on andoid.test.base, android.test.mock
and android.test.runner where necessary.
* Adds <uses-library android:name="android.test.runner"/> to any
affected package to ensure that the classes that were included by
legacy-android-test are still available at runtime. That also adds a
dependency on android.test.base and android.test.mock.
The following change descriptions were generated automatically and so
may be a little repetitive. They are provided to give the reviewer
enough information to check the comments match what has actually been
changed and check the reasoning behind the changes.
* test-runner/tests/Android.mk
Added 'android.test.base' and 'android.test.mock' to
LOCAL_JAVA_LIBRARIES because FrameworkTestRunnerTests's source
depends on their classes and because of these changes they are no
longer present on the compilation path.
Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
because statically including the classes in
FrameworkTestRunnerTests results in duplicate classes which leads
to build time and compile time issues.
Bug: 30188076
Test: make checkbuild
Change-Id: I52a91fe4f6016de8edf4753fbd2bc4d2e4c9f317
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.
PackageInfoSources only provided a static field and accessor method so
they were moved into ClassPathPackageInfoSource and PackageInfoSources
was removed.
ClassPathPackageInfo was only used in ClassPathPackageInfoSource and in
TestGrouping. In the latter it was simply used as an intermediate value
between ClassPathPackageInfoSource.getPackage(String packageName) and
ClassPathPackageInfo.getTopLevelClassesRecursive(String packageName).
Moving that method into ClassPathPackageInfoSource allowed the
ClassPathPackageInfo to become an inner class of
ClassPathPackageInfoSource. As it is an inner class it no longer needed
an explicit reference to the containing ClassPathPackageInfoSource.
Bug: 30188076
Test: make checkbuild and ran FrameworkTestRunnerTests
Change-Id: Idb0b6a585030805b9cff8562abb93b7e5920c53a
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.
The HasClassAnnotation and HasMethodAnnotation were never used
separately and only used by HasAnnotation. This merges the functionality
into a single nested class in TestPredicates, hidden behind the new
TestPredicates.hasAnnotation(). The HasAnnotationTest was renamed as
TestPredicatesTest and the HasClassAnnotationTest and
HasMethodAnnotationTest classes were removed as their tests provide no
additional coverage. The removal of the Has*Annotation.java files means
that the test-runner/src/android/test/suitebuilder/annotation/ directory
is empty apart from the package.html file so that was moved to
legacy-test to sit alongside the actual annotation classes.
The Predicates class, while part of the legacy-test module was only
ever used by the test-runner module and only its not() method was
actually used. So, the not() method and associated nested class were
moved to TestPredicates, the tests for not() were moved to
TestPredicatesTest and the Predicates* classes were removed.
That allowed for the removal of the legacy-android-tests as that is now
empty.
TestPredicates has a number of constants that were public. They were
hidden by moving them to the class that actually used them.
A minor generic issue was fixed in AssignableFrom.
Bug: 30188076
Test: make checkbuild and run FrameworkTestRunnerTests
Change-Id: I861da388a4146bb28e1e480d1b7ba9137b7b270e
Part of the work of removing JUnit and dependent android.test classes
from the Android API involves providing a static library that developers
can include in their test applications to ease migration. That library
will be built directly from the source (as opposed to android.jar which
is built from stubs) and so developers will be able to see classes and
methods that are not present in the stubs. This change is one of a
number of similar changes that cleanup the existing non-API code in
order to minimize the additional methods and classes exposed externally.
The basic approach is to remove unused classes and methods, use least
visible access modifier possible and generally minimize the amount of
publicly visible code.
TestCaseUtil.getTestCaseNames() is only used by tests but its tests did
provide some coverage of the getTests() method so remove the method and
the tests the method was simply moved into TestCaseUtilTest and the
tests renamed to make it clearer that they are testing
TestCaseUtil.getTests().
Similarly, TestCaseUtil.createTestSuite() was only used by tests but its
tests did provide some coverage of the invokeSuiteMethodIfPossible()
method so the tests were modified and renamed to preserve that coverage.
TestCaseUtil.getTestAtIndex() was completely unused so was just removed.
Bug: 30188076
Test: make checkbuild and ran FrameworkTestRunnerTests
Change-Id: I62bbdbab428d7560f0c7df11f313fe60cfd31d13
It looks as though the tests in test-runner/tests have not actually been
run successfully for over 7 years. As a result they have degraded. This
change fixes the tests so that they will pass and provides instructions
on how to run them.
TestCaseUtilTest.testGetTestCaseNamesForTestSuiteWithSuiteMethod
This fails because it expected 2 names to be returned but only
returns 0. The reason for that is although TwoTestsInTestSuite has a
Test suite() method that does create a TestSuite with two tests the
TestCaseUtil method does not actually call suite(). Instead, because
TwoTestsInTestSuite is a TestSuite it just calls the tests() method
on it which returns an empty Enumeration because TwoTestsInTestSuite
is empty.
The support for "static Test suite() {}" is broken but fixing this
will affect the behavior of InstrumentationTestRunner which is used
in thousands of different places both in and outside Google and so
could cause untold problems.
TestSuiteBuilderTest.testIncludeAllPackagesUnderHere
Reformat the list, one per line and then add missing name
"testPublicConstructor".
ErrorTest/FailingTest
These tests are not meant to be run on their own, only as part of a
separate test. The RunAsPartOfSeparateTest annotation was added to
allow these to be excluded using notAnnotation as shown in the
instructions for running the tests.
Bug: 30188076
Test: followed new instructions in test-runner/tests/Android.mk
Change-Id: I60e7bee9cd08a9ab7777a2578fc58da772de5c1f
TestGrouping is not part of the API but is used by classes that are and
so will need to be included in the static library we ship as part of the
SDK. As that library will be built directly from the source (as opposed
to android.jar which is built from stubs) developers will be able to see
classes and methods that are hidden and so not present in the stubs.
This change makes TestGrouping and its members as inaccessible as
possible. Unused methods and fields were removed and the TestGrouping
class was simplified by passing the ClassLoader into the constructor,
initializing the classLoader, making the classLoader field final,
and removing the setClassLoader(ClassLoader) method.
Bug: 30188076
Test: make checkbuild
Change-Id: Ie0545b1a61b74cdbc78667417f360b5197e2e128
In preparation for building android.legacy.test library against
the SDK this removes a dependency on internal classes.
Bug: 30188076
Test: make checkbuild
Change-Id: I9ea3827ab5db167c8cbddad25f0815c942681092
In preparation for removing junit classes from the Android API
the legacy-test target will be removed from the
TARGET_DEFAULT_JAVA_LIBRARIES. This change adds explicit
dependencies on junit and/or legacy-android-test to ensure that
modules will compile properly once it is removed.
(cherry picked from 6387604f9e672ece85e07c4bcbd7be396867f06f)
Bug: 30188076
Test: make checkbuild
Merged-In: I13e88297731253420e4e5f5291d503f13a39a156
Change-Id: I58446eb8c45d8ac2bcdbc9fa40d1321e811bdd4b
This commit fixes two somewhat related problems:
- Attempting to run a method which does not exist caused a runtime
exception which stopped the test run. Change this so the runner reports
an individual test failure instead
- A runtime exception during the test run would cause it to stop
completely, with no information dumped to the logcat or stdout. Now
exceptions are trapped and reported to stdout.
Also added associated unit tests to test these two conditions.
Related bug 2812262.
Change-Id: I383f9b9bad99f14cb51071800fa9bdbf6a6a1119
The test runner will only load TestCase classes that have a public
constructor with either no params or a single String parameter.
This is fairly subtle behavior and can be difficult to catch. This change
adds a log message when a TestCase class is not loaded, and adds some
associated unit tests.
Change-Id: I6fc63e4179c949620f5773e0ae134f99905a6fb2
And ability to exclude tests with given annotation.
Also fix class cast compile warning in emma output method.
Bug 2239240
Change-Id: I56273a51a8c58a690680bdb612615fab69e6e13f