Software Testing Best Practices
Software testing is important for quality assurance. Best practices in software testing can provide high-end software at the end. In this blog I am sharing some of best practices in software testing from my personal experience.
1. Test Case Creation:
Once the requirements are approved and frozen tester need to start the test case creation
process. When development team is writing the code or development is in process, the
test case preparation is started in parallel and completed to avoid any hustle during the QA
execution. When writing the test cases proper information needs to be added in the test
cases sheet – TC_Id, Objective, Steps, Expected Result, Actual Result, Test Data, Status,
He/she need to cover the negative test cases, positive test cases, regression test cases and
smoke test cases.
2. Prepare regression test cases list:
Regression test cases are very important. Whenever there comes a new build of the
software, there is always a chance that the old functions of the software might be
impacted. You should have a regression test cases list prepared so as
to check the existing functionality is not obstructed.
3. Positive Testing and Negative Testing:
The positive test cases are created based on the requirements. Positive Testing is type of testing in which the testing is done to check the software is meeting the requirements through positive scenarios. Tester need to mention the correct/valid data for all the fields. Negative Testing is performed when you want to check the software for negative scenarios and to break the code . The tester needs to put some error values in the application to be tested. e.g wrong date formats, putting decimals, colons in number formats.
4. Performance Testing:
Performance testing is the process of determining the speed or effectiveness of a
computer, network, software program or device. This process can involve quantitative tests
done in a lab, such as measuring the response time or the number of MIPS (millions of
instructions per second) at which a system functions. And qualitative attributes like reliability, scalability and interoperability can also be evaluated. Generally performance testing is done in association with stress testing. The process can compare two or more devices or programs for the parameters like speed, data transfer rate, bandwidth, throughput, efficiency or reliability.
5. Test Case Preparation and Review:
The test case should contain all the steps of execute the test. It should be easily understood
by any person on test cases. Some best practices for test case creation are:
The test cases should be mapped with the requirements to create a better
understanding of the test case.
- There should be a test case name, number, requirement and description of test case.
- Log in information should always be written.
- Write the test case type e.g. negative test case, positive test case.
6. User Acceptance Testing:
When the application is handed over to the client, entire documentation should be made
explaining the method of installation, any open defects.
Unit Test Mechanism in Salesforce
1. Single action
Here user need to test to verify that a single record produces the correct/ expected result.
So created the unit test data in your test class.
2. Bulk actions
User need to test not only for single record he/she need to test for bulk records as well,
may be invoked for 1 to 200 records.
3. Restricted user
Test whether a user with restricted access to the sObjects used in your code sees the
expected behavior. That is, whether they can run the code or receive error messages.
Always use RunAs for to check user access on sObjects.
4. Positive behavior
User need to test first for positive test cases it included filling the data correctly and it did
not go past limits.
5. Negative behavior
User must test for the negative test cases as well. If there is an amount field, then he/she
needs to test for negative amount. User must test for the negative case and verify that the
error messages are correctly produced as well as for the positive, within the limits case.
Testing Best Practices in Salesforce
1. Set up test data
- Create the necessary data in test classes, so the tests do not have to rely on data in
a particular organization. - Create all test data before calling the Test.startTest method.
- Since tests don’t commit, you won’t need to delete any data.
Write comments stating not only what is supposed to be tested, but the assumptions the
tester made about the data, the expected outcome, and so on.
Test the classes in your application individually. Never test your entire application in a
single test.
Best Practices for Parallel Test Execution
Tests that are started from the Salesforce user interface (including the Developer Console)
run in parallel. Parallel test execution can speed up test run time. Sometimes, parallel test
execution results in data contention issues, and you can turn off parallel execution in those
cases. In particular, data contention issues and UNABLE_TO_LOCK_ROW errors might
occur in the following cases:
- When tests update the same records at the same time. Updating the same records
typically occurs when tests don’t create their own data and turn off data isolation to
access the organization’s data. - When a deadlock occurs in tests that are running in parallel and that try to create
records with duplicate index field values. A deadlock occurs when two running tests are
waiting for each other to roll back data, which happens if two tests insert records with
the same unique index field values in different orders.