Coder Social home page Coder Social logo

svendelporte / smartfactory-for-force.com Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mbotos/smartfactory-for-force.com

0.0 0.0 0.0 93 KB

Creates test data objects with all required fields and object lookups pre-populated.

License: Apache License 2.0

smartfactory-for-force.com's Introduction

SmartFactory for Force.com

SmartFactory aims to provide test data objects with all required fields and object lookups pre-populated.

The idea came from writing unit tests for unfamiliar orgs, where setting up test data might mean digging through a large hierarchy of lookup relationships and required fields. Instead, SmartFactory uses the Describe metadata to populate all fields with data of the right type. For lookup fields, it creates an appropriate object and then uses that object's id.

The Evolution of Test Data provides an introduction to the problem and SmartFactory's solution.

The initial version won the Mavens Consulting 2011 hackathon.

Installation

For an easy, 1-click installation: SmartFactory for Force.com on Code Share

To use the source code with a Salesforce org: How To Use Github and the Force.com IDE

To prevent the large number of system calls from filling the debug log, you may also want to set logging filter overrides for the SmartFactory class. (Setup - Develop - Apex Classes - SmartFactory - Log Filters - System = NONE)

Usage

Just use SmartFactory in your tests to create objects:

Account account = (Account)SmartFactory.createSObject('Account');

To cascade and create lookup objects:

Contact contact = (Contact)SmartFactory.createSObject('Contact', true);

The same syntax is used for custom objects:

Custom_Object__c customObject = (Custom_Object__c)SmartFactory.createSObject('Custom_Object__c');

See SmartFactory_Test for additional examples.

Future Work

TODO comments note areas for additional development. Key areas include:

  1. Provide an field override map that allows callers to specify default values for specific objects and fields
  2. Provide a recursion limit for lookups to the same object type

Help and Discussion

For help and discussion, please use the project's Google Group.

smartfactory-for-force.com's People

Contributors

mbotos avatar fractastical avatar thysmichels avatar dschach avatar abhinavguptas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.