DUnit is used to test or display functions or components to others.
dependencies {
compile 'top.ftas:dunit:2.1'
annotationProcessor 'top.ftas:dunit-compiler:2.1'
}
Add annotations to existing activities:
```java
@DUnit
public class BaseActivity extends Activity{ /* Do something */ }
```
-
Define groups:
@DUnitGroup("HttpGroup") public class HttpGroup extends DUnitRootGroup{}
or
@DUnitGroup public class ObjectGroup { }
-
Create a display unit:
@DUnit( name = "RetrofitDisplayUnit", group = HttpGroup.class ) public class RetrofitDisplayUnit extends AbstractDisplayUnit{ @Override public void callUnit() { /* Do something */ } }
```sh
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments = [DUNIT_MODULE_NAME : "sample"]
}
}
}
}
```
```sh
kapt {
arguments {
arg("DUNIT_MODULE_NAME", "sample_kotlin")
}
}
```
@DUnit(name = "SampleTestLibraryActivity - paramJson",paramJson = "{\"testName\":\"I am from other library!\",\"testAge\":18}")
public class SampleTestLibraryActivity extends Activity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sample_test_library);
TextView textView = (TextView) findViewById(R.id.hello_txt);
String str = "Hello,SampleTestLibraryActivity!";
Intent intent = getIntent();
if (intent != null) {
str += "\nname:" + intent.getStringExtra("testName");
str += "\nage:" + intent.getIntExtra("testAge", -1);
}
textView.setText(str);
}
}