Home | History | Annotate | Download | only in com.android.ide.eclipse.tests
      1 This project contains the tests for the Android Eclipse Plugins.
      2 
      3 You can do three things:
      4 1- Run the unit tests as a full "eclipse plugin" suite
      5 2- Run the unit tests as independent JUnit tests (not as plugin)
      6 3. Run the functional tests as a full "eclipse plugin" suite (require a real SDK)
      7 
      8 The unit tests are isolated tests that do not require external dependencies such as an SDK. 
      9 The functional tests are higher level tests that may require a real SDK.
     10 
     11 ------------------------------------------
     12 1- Running the unit tests as a full "eclipse plugin" suite
     13 ------------------------------------------
     14 
     15 Steps to run the test suite:
     16 
     17 A- In Eclipse, import following projects from development/tools/eclipse/plugins:
     18 	- adt-tests
     19 	- adt
     20 	- ddms
     21 
     22 B- Create a new "JUnit Plug-in Test" run configuration via the "Run > Open Run Dialog..." menu
     23 Set the launch configuration's data as follows:
     24 i. "Test" tab: 
     25   Select "Run a single test"
     26   Project: adt-tests 
     27   Test class: com.android.ide.eclipse.tests.UnitTests
     28   Test runner: JUnit 3
     29 ii. "Arguments" tab:
     30  Set "VM Arguments" to 
     31 "-Dtest_data=<adt>/plugins/com.android.ide.eclipse.tests/unittests/data/"
     32 replacing "<adt>" with absolute filesystem path to the android plugin source location
     33 
     34 All other fields can be left with their default values
     35 
     36 C. Run the newly created launch configuration
     37 
     38 Running the tests will run a secondary instance of Eclipse. 
     39 
     40 Please note the following constraints to be aware of when writing tests to run within a plugin environment:
     41 
     42 a. Access restrictions: cannot access package or protected members in a different
     43 plugin, even if they are in the same declared package 
     44 b. Using classloader.getResource or getResourceAsStream to access test data will 
     45 likely fail in the plugin environment. Instead, use AdtTestData to access test files
     46 in conjunction with the "test_data" environment variable mentioned above
     47 
     48 
     49 -------------------------------------------
     50 2- Run the unit tests as independent JUnit tests (not plugin)
     51 -------------------------------------------
     52 
     53 A- In Eclipse, import following projects from development/tools/eclipse/plugins:
     54 	- adt-tests
     55 	- adt
     56 	- ddms
     57 
     58 B- Select the "unittests" source folder, right-click and select
     59 	"Run As > JUnit Test" (i.e. not the plugin tests)
     60 
     61 This creates a debug configuration of type "JUnit Test" running all tests
     62 in the source folder "unittests". The runtime must be JUnit 3.
     63 
     64 Note: this method runs the tests within a regular JVM environment (ie not within
     65 an Eclipse instance). This method has the advantage of being quicker than running
     66 as a JUnit plugin test, and requires less potential set-up, but has the 
     67 disadvantage of not properly replicating how the tests will be run in the 
     68 continuous test environment. Tests that pass when run as "JUnit Tests" can
     69 fail when run as "JUnit Plugin Tests", due to the extra constraints imposed by
     70 running within an Eclipse plug-in noted in section 1.
     71 
     72 ------------------------------------------
     73 3- Running the functional tests as a full "eclipse plugin" suite
     74 ------------------------------------------
     75 
     76 Steps to run the test suite:
     77 
     78 A- In Eclipse, import following projects from development/tools/eclipse/plugins:
     79 	- adt-tests
     80 	- adt
     81 	- ddms
     82 
     83 B - Setup an SDK on host machine, that is compatible with the Eclipse ADT plugins under test
     84 
     85 C- Create a new "JUnit Plug-in Test" run configuration via the "Run > Open Run Dialog..." menu
     86 Set the launch configuration's data as follows:
     87 i. "Test" tab: 
     88   Select "Run a single test"
     89   Project: adt-tests 
     90   Test class: com.android.ide.eclipse.tests.FuncTests
     91   Test runner: JUnit 3
     92 ii. "Environment" tab:
     93  Add a "sdk_home" environment variable, setting its path to the SDK from step B
     94 
     95 All other fields can be left with their default values
     96 
     97 D. Run the newly created launch configuration
     98 
     99 Running the tests will run a secondary instance of Eclipse. 
    100 
    101 
    102