Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An Android library for generating simple A/B tests

License

NotificationsYou must be signed in to change notification settings

MattAFRL/abtestgen

Repository files navigation

...that makes writing simple tests simpler by using annotations.

Android Arsenal

How it works

Currently you can use two different annotations:@TextTest and@ResourceTest.@TextTest is for plugging Strings into a generated test;@ResourceTest is for plugging resource IDs. Example usage may be as follows:

@TextTest(testName="firstTest",method="setText",values={"hello","howdy"})TextViewhelloTextView;

which will automatically generate a class which you can run by callingABTester.with(activity).run("firstTest");. Or, if you're running the test from outside of an Activity,ABTester.with() can also take a second Object parameter where you've put in the annotations.

You can also cover multiple fields in the same test, as follows:

@TextTest(testName="firstTest",method="setText",values={"hello","howdy"})TextViewhelloTextView;@ResourceTest(testName="firstTest",method="setText",values={R.string.yo,R.string.sup})TextViewotherTextView;@TextTest(testName="firstTest",method="setText",values={"world","globe"})TextViewthirdTextView;

And that will generate a class which will create two tests that will cover those three TextViews.

There's also aCustomTest class which allows you to define more complex tests that may not be possible to generate with the annotation processor.

By default, tests will be weighted to have an equal chance to be selected. However, by extending theTestPicker class you can weight the tests however you like.

To obtain...

You'll want to include

maven { url"https://jitpack.io" }

in either yourallprojects.repositories or your module'srepositories section. Whatever you like!

You will also need the APT plugin, so you will want to put this into your root build.gradle'sbuildscript.dependencies:

classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'

and apply this plugin to the modules you're doing your tests in:

applyplugin:'com.neenbedankt.android-apt'

Then, you'll want to bang these bad boys into yourbuild.gradles' dependencies:

apt'com.github.imperial-crystalline-recursion.abtestgen:ab-compiler:0.4.1'compile'com.github.imperial-crystalline-recursion.abtestgen:ab-annotations:0.4.1'compile'com.github.imperial-crystalline-recursion.abtestgen:ab-lib:0.4.1'

[8]ページ先頭

©2009-2025 Movatter.jp