利用Tesforce高效地进行Apex Test Class编程

1.Why Tesforce

The Test Classes are required to deploy Apex to a production environment or to be packaged and placed on Force.com AppExchange, it must provide at least 75% code coverage.

That will be a huge workload to SFDC Developers if the project(application) include a lot of Apex Classes,the cost of time to write Test Classes for them even more than to write themselves.So why cannot generate the Test Code automatically,or how can we write the test code more efficiently? We(at least me) really need a application which can generate most of code that we don’t have to write, such as Test Data Creating,can solve the potential problems of reference fields and required fields for us, and more.

Tesforce is the application I created to satisfy the needs, which is dedicated to minimize our coding work and help us to focus on the application logic.

Let me show you the basic usage of Tesforce.

2.Usage of Tesforce

Sample Test Class

2.1 New a Project

Create a project with your SFDC account and password.If you don’t want your password to be saved,don’t forget to off the “Save Password” checkbox.
And Tesforce also supports adding project through Salesforce OAuth2, by click “Login with Salesforce” button.
1. New Project

2.2 New a Test Class

Create a Test Class for the Apex Class.
2. New TestClass

2.3 New a Test Case

A Apex TestMethod is handled as a Test Case in Tesforce.
3. New TestCase

2.4 Select an existing data

Choose any existing data as a “Data Template”,Tesforce will solve the problems such as reference fields, required fields and the others.
4. Search TestData 5. TestData Assignment 6. TestData Assignment

2.5 Make up Header and Footer

Now add Apex Test Code into header tag or footer tag by necessity,such as setting parameters for ApexPages,or run an Apex Class.
7. Add Footer 8. Add Footer

2.6 Apex Code Generator

The Apex Code will be generated automatically in background. 9. Code Generator

2.7 Deploy Test Class to Salesforce

10. Deploy TestClass

2.8 Run Test

11. RunTest

Test Results

12. Test Results 13. Test Results Since it is still in beta, please do keep in mind that there may be bugs. I encourage you to send your feedback if you encounter them and also to share your ideas for what would make it even more awesome.

Enjoy Tesforce. It’s better up here. ; )

Related Post

Salesforce DevTools – Force.com开发者必备Chrome扩展... Salesforce DevTools是针对Force.com开发者开发的具备以下功能的Chrome扩展: ・自动生成Object数据接口文档(Excel)。 ・自动生成Salesforce数据模型的ER图svg文件。 ・在对象详细页面上,一键显示 / 隐藏对象API名。 ・自动生成测试数据的Apex Code,以及SOQL文 ・快捷打开Object的新建,列表及设定页面 ・简档,对象字段权限页面的All check功能 目前为止,这个扩展支持English, 日本語, 中文(繁體)或 中文(简体)版的Salesforce.com。 从Chrome Web Stor...
Pipeline for Salesforce – Be less busy, less... Overview Pipeline is a metadata deploy app for Salesforce, supports: ・Making Changeset with Excel file in seconds. ・Exporting Pipeline target metadata list to Excel file. ・No dependencies on Salesforce Org, deploying metadata between any different organizations. ・Deploying metadata base o...
Salesforce批量编辑 (Chrome扩展) – 在任何标准视图上进行批量插入, ... "Salesforce批量编辑"是今年发布的第二个Chrome扩展功能(第一个在这里),具备以下机能: ・轻松将标准列表视图转变成功能强大的批量编辑器 ・批量插入,批量拷贝,批量更新,批量删除,所有功能都具备,同时支持Classic跟Lightning! ・支持将数据导出到CSV文件中 ・支持从Excel直接拷贝粘贴复数行・复数列的数据 "Salesforce批量编辑"支持几乎所有的Salesforce列表视图、no页面跳转,no附加设定,no kidding。 注意 : 在Classic上使用时,请确保不要勾选“Session Settings”中的“Require H...
Salesforce Smart Importer – 1-Drag to import... This is my third Chrome Extension named Salesforce Smart Importer (Other two popular extensions are Salesforce Mass Editor and Salesforce DevTools), it is designed for Salesforce not only admin but also normal user, supports : ・1-Drag to import any Excel / CSV data on anywhere in Salesforce, both ...