Burst


Source link: https://github.com/square/burst

Burst

A unit testing library for varying test data.

Usage

Burst is a set of test runners which rely on enums for varying both the instantiation of test classes and the methods inside of them.

Define an enum for the property you wish to vary.

public enum Soda {

PEPSI, COKE 
}

The enum can be simple as above, or contain data and methods specific to what you are testing.

public enum Sets {

HASH_SET() {

  @Override public <T> Set<T> create() {

 return new HashSet<T>();

  
}

}
,
LINKED_HASH_SET() {

  @Override public <T> Set<T> create() {

 return new LinkedHashSet<T>();

  
}

}
,
TREE_SET() {

  @Override public <T> Set<T> create() {

 return new TreeSet<T>();

  
}

}
;
 public abstract <T> Set<T> create();
 
}

Annotate your test class to use the BurstJUnit4 runner.

@RunWith(BurstJUnit4.class) public class DrinkSodaTest {

// TODO Tests... 
}

An enum that appears on a test constructor will cause all the enclosed test to be run once for each value in the enum.

public DrinkSodaTest(Soda soda) {

// TODO Do something with 'soda'... 
}

Combine multiple enums for the combination of their variations.

public DrinkSodaTest(Soda soda, Sets sets) {

// TODO Do something with 'soda' and 'sets'... 
}

This will be called with the constructor arguments [ PEPSI & HASH_SET, PEPSI & LINKED_HASH_SET, PEPSI & TREE_SET, COKE & HASH_SET, ..].

If your constructor is just setting fields, you can just annotate the fields with @Burst.

@RunWith(BurstJUnit4.class) public class DrinkSodaTest {

@Burst Soda soda;
@Burst Sets sets;
// TODO Tests... 
}

This behaves just like the above example.

Note: Classes can either have constructors with arguments or annotated fields. A class with both will cause the test runner to throw an exception.

Methods may also be varied using one or more parameters that are enums.

@Test public void drinkFavoriteSodas(Soda soda) {

// TODO Test drink method with 'soda'... 
}

Having both constructor (or field) variation and method variation is supported.

@RunWith(BurstJUnit4.class) public class DrinkSodaTest {

private final Set<Soda> favorites;
 public DrinkSodaTest(Sets sets) {

  favorites = sets.create();

}

 @Test public void trackFavorites() {

  // TODO ...

}

 @Test public void drinkFavoriteSodas(Soda soda) {

  // TODO ...

}
 
}

The trackFavorites test will be executed 3 times, once for each Sets value. The drinkFavoriteSodas test, however, is executed 6 times, for each of the three Sets values it runs twice for each Soda.

If a particular variation or variation combination does not make sense you can use assumptions to filter either directly in the test or as a custom rule.

Download

  • JUnit 4

    A test runner which can be used for JUnit 4.

    com.squareup.burst:burst-junit4:1.2.0 
  • Core library

    Contains the core logic which creates the combinations of arguments for both constructors and method. Usually not useful on its own.

    com.squareup.burst:burst:1.2.0 

Snapshots of the development version are available in Sonatype's snapshots repository.

License

Copyright 2014 Square, Inc.  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. 

Resources

A mini elegant WebView for fast easy access.

Feature list:

  • no more memory leak
  • easy web page margin fixed
  • easy web video implementation
  • easy web content display implementation
  • took care of life cycle issues
  • fantasy animation reveal fade in

Root Checker basically checks your device whether it is rooted or not.

Dewey is an android widget designed to hold an unlimited number of tabs, making it ideal for allowing pagination through a list.

Thin DownloadManager is an android library primary to download files and to avoid using DOWNLOAD_WITHOUT_NOTIFICATION permission when using Android provided DownloadManager in your application.

Simple image blurring for Android.

A lightweight, flexible tip dialog in Android.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes