{"id":18787694,"url":"https://github.com/xionxiao/app4unit","last_synced_at":"2025-12-23T21:30:27.304Z","repository":{"id":229653626,"uuid":"289723457","full_name":"xionxiao/App4Unit","owner":"xionxiao","description":"JUnit like automatic testing framework for real application.","archived":false,"fork":false,"pushed_at":"2021-03-24T15:23:47.000Z","size":279,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T13:25:38.262Z","etag":null,"topics":["android-test","annotations","appium","junit4"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xionxiao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-08-23T16:24:14.000Z","updated_at":"2021-05-28T04:02:56.000Z","dependencies_parsed_at":"2024-03-25T17:15:51.991Z","dependency_job_id":"242b9a3e-682d-4ee6-8390-ddc07f22aae5","html_url":"https://github.com/xionxiao/App4Unit","commit_stats":null,"previous_names":["xionxiao/app4unit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xionxiao%2FApp4Unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xionxiao%2FApp4Unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xionxiao%2FApp4Unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xionxiao%2FApp4Unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xionxiao","download_url":"https://codeload.github.com/xionxiao/App4Unit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239707908,"owners_count":19684156,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-test","annotations","appium","junit4"],"created_at":"2024-11-07T20:55:29.674Z","updated_at":"2025-12-23T21:30:21.767Z","avatar_url":"https://github.com/xionxiao.png","language":"Java","readme":"[![Travis CI](https://travis-ci.org/xionxiao/App4Unit.svg)](https://travis-ci.org/xionxiao/App4Unit)\n\n# App4Unit\n\nJUnit like automatic testing application framework. This framework can help developers to build real test applications and create test cases using JUnit like style. It also contains Appium script for automation test and build test matrix.\n\n## Setup\n\n### 1. Pre-request\n\n- Android Studio 3.0\n\n    \u003chttps://developer.android.com/studio/index.html\u003e\n\n- JUnit 4.12\n- Appium\n\n### 2. Compile \u0026 Run\n\n#### Standalone\n\nClone the repo and import to Android Studio. Connect real device and Run AutoTestApp.\n\n#### Auto run with multiple devices\n\n1. Build the project\n\n    ```shell\n    ./gradlew app:assembleDebug\n    ```\n\n1. Start Appium Server\n\n1. Get device list with adb\n\n    ```shell\n    adb devices\n    ```\n\n1. Run autotest script\n\n    ```shell\n    python script/autotest.py -d \u003cdevice serail numbers seperated by comma\u003e\n    ```\n\n    for more information execute\n\n    ```shell\n    python script/autotest.py -h\n    ```\n\n## Usage\n\n### How To Add Test Cases\n\nThis test framework is very similar to JUnit4. If you familar with JUnit4 unit testing. You can create your own test use that schema.\n\n#### 1. Add a new test class\n\n```java\n@Description(\"My Simple Test\")\npublic class MyTestCase {\n    @BeforeClass\n    public static void setupClass() {\n        // static setup before test class\n    }\n\n    @Before\n    public void setup() {\n        // Setup code\n    }\n\n    @Test\n    public void myTestFunction1() {\n        assertEquals(4, 2 + 2);\n    }\n\n    @Test\n    public void myTestFunction2() {\n        assertNotEquals(4, 2 + 1);\n    }\n\n    @After\n    public void tearDown() {\n        // Clean up\n    }\n\n    @AfterClass\n    public static void tearDownClass() {\n        // static teardown after test class\n    }\n}\n```\n\n#### 2. Create a TestRunner\n\n```java\nTestRunner runner = new TestRunner();\n```\n\n#### 3. Run test/suite\n\n```java\n//Run a single test\nrunner.run(MyTestCase.class)\n\n//Run test suite\nTestSuite suite = new TestSuite();\nsuite.add(MyTestCase.class)\nrunner.run(suite);\n```\n\n### Asserts\n\nThis test framework reuses [org.junit.Assert] as it's assertion mechanism. To use assertion in TestCase:\n\n### Assertions\n\n```java\nimport static com.sparktest.autotesteapp.framework.*\n```\n\n### Injection\n\nYou can use dagger dependency injection in test cases.\n\n- Provide a Module\n\n```java\nimport javax.inject.Singleton;\n\nimport dagger.Module;\nimport dagger.Provides;\n\n@Module(\n        injects = {\n                TestTest.class,\n        }\n)\npublic class TestModule {\n    Context context;\n\n    public TestModule(Context context) {\n        this.context = context;\n    }\n\n    @Provides\n    @Singleton\n    public Context provideContext() {\n        return this.context;\n    }\n}\n```\n\n- Use Inject in Test Case\n\n```java\npublic class TestTest {\n    @Inject\n    Context context;\n\n    @Test\n    public void run() {\n        assertNotNull(context);\n    }\n}\n```\n\n## Annotations\n\n### @Description\n\nDescriptions of TestCase and Test methods. Description will be displayed on TestCaseListView. If no @Description annotation, class name will be used.\n\n### @Test\n\nMethods to test. Methods annoted with @Test should be public method.\n\n### @BeforeClass\n\nMethod annoted with @BeforeClass will be executed before class instantiated. This method should be public static method.\n\n### @AfterClass\n\nMethod annoted with @AfterClass will be executed after all test method are finished or test case failed. This method should be public static method.\n\n### @Before\n\nMethod annoted with @Before will be executed before every @Test method execution.\n\n### @After\n\nMethod annoted with @After will be executed after every @Test method execution.\n\n### @Ignore\n\nMethod or Class annoted with @Ignore will be ignored.\n\n## Async await/resume\n\n## ThreadSafe\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxionxiao%2Fapp4unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxionxiao%2Fapp4unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxionxiao%2Fapp4unit/lists"}