diacetyl

Butterflavor for Butterknife tests

License

License

GroupId

GroupId

de.jodamob.android
ArtifactId

ArtifactId

diacetyl
Last Version

Last Version

0.5.1
Release Date

Release Date

Type

Type

aar
Description

Description

diacetyl
Butterflavor for Butterknife tests
Project URL

Project URL

https://github.com/dpreussler/Diacetyl
Source Code Management

Source Code Management

https://github.com/dpreussler/Diacetyl

Download diacetyl

How to add to project

<!-- https://jarcasting.com/artifacts/de.jodamob.android/diacetyl/ -->
<dependency>
    <groupId>de.jodamob.android</groupId>
    <artifactId>diacetyl</artifactId>
    <version>0.5.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/de.jodamob.android/diacetyl/
implementation 'de.jodamob.android:diacetyl:0.5.1'
// https://jarcasting.com/artifacts/de.jodamob.android/diacetyl/
implementation ("de.jodamob.android:diacetyl:0.5.1")
'de.jodamob.android:diacetyl:aar:0.5.1'
<dependency org="de.jodamob.android" name="diacetyl" rev="0.5.1">
  <artifact name="diacetyl" type="aar" />
</dependency>
@Grapes(
@Grab(group='de.jodamob.android', module='diacetyl', version='0.5.1')
)
libraryDependencies += "de.jodamob.android" % "diacetyl" % "0.5.1"
[de.jodamob.android/diacetyl "0.5.1"]

Dependencies

compile (5)

Group / Artifact Type Version
de.jodamob.android : mockitoid jar 0.6
org.mockito : mockito-all jar 1.9.5
de.jodamob.android : SuperReflect jar 1.0
com.android.support » recyclerview-v7 jar 23.2.1
com.android.support » cardview-v7 jar 23.2.1

Project Modules

There are no modules declared in this project.

Build Status Maven Central

Diacetyl

Diacetyl ... is added to some foods to impart its buttery flavor. (source: wikipedia)

logo

It adds artifical butterflavor to your Butterknife in test environments. When running unit tests you don't need to run Butterknife or similar as this might need real views which leads to the use of Robolectric or similar.

class MyButterKnifeActivtiy {
    ...
    @Bind TextView textView;
    @Bind EditText editText;
    ...

class MyButterKnifeActivtiyTest {

  @Test 
  public void test() {
 	 MyButterKnifeActivtiy tested = new MyButterKnifeActivtiy();
	 Diacetyl.butterForTests(tested);

Diacetyl initializes any android view found as a field for a given class with a mockito mock.

  • There is no need to run Butterknife logic.
  • It will look into parent classes too.
  • It will mock custom views too
  • It will ignore fields that already have a value.
  • It is not bound to Butterknife, it does not check for annotations and is not looking into your layouts.
  • It will use mockitoid mocks (mockito mocks with some enhancements) if available else simple mockito mocks.

You can pass multiple classes into, for viewholder for example.

	 Diacetyl.butterForTests(viewHolder1, viewHolder2);

Gradle

repositories {
    ...
    maven { url 'https://oss.sonatype.org/content/repositories/staging/'}
}
...

dependencies {
    testCompile 'de.jodamob.android:diacetyl:0.5.1'
}

Todo

  • performance measurements and maybe optimization

License

Pam Cooking Spray Image, copyright Mike Mozart, CC by 2.0, https://www.flickr.com/photos/jeepersmedia/15203456322


Libray Copyright 2016 Danny Preussler
Uses SuperReflect https://github.com/dpreussler/SuperReflect
based on jOOR, 2011-2013, Lukas Eder, [email protected]

Both licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
0.5.1
0.5