in Software Development
for 20 Years
in Software Development for 20 Years
COST-EFFECTIVE
Maximize ROI with our cost-effective, high-quality outsourcing software development solutions.
TECH-SKILLS
Proficient in cutting-edge technologies, crafting tailored software solutions to match your business requirements.
EXPERIENCE
Leverage our two decades of experience in software outsourcing for proven, results-oriented development methodologies.
EXPERTISE
As an award-winning offshore software development company, our team is diverse and well versed in a variety of expertise in software development outsourcing. We are up-to-date with the cutting- edge technologies and best software development practices.
FINTECH
Develop a wide range of applications in financial industries.
business
Provide inclusive services from system development to maintenance.
medical
Have notable experience in developing applications in medical field..
website
Many achievement in application development, system by CMS and built website campaign combined with SNS.
mobile
Develop mobile applications with beautiful UI on several platforms.
middleware &
embedded
Middleware development basing on Android, and embedded software development and porting.
protocol &
communication
Develop protocol stack such as WiMAX and WiFi. Control software development of Mobile Phone Base Station.
CLOUD
INFRASTRUCTURE
Robust, scalable, and secure architectures that leverage cutting-edge technologies for optimal performance and efficiency.
FEATURED CONTENT
Mocking in Python's Unittest
Mocking is a powerful technique in unit testing that allows developers to simulate the behavior of complex dependencies or external systems. In Python's unittest framework, the unittest.mock
module provides robust support for creating and working with mock objects. This topic delves into the concept of mocking and demonstrates its usage within Python's unittest framework.
Concept of Mocking:
Mocking involves substituting real objects or functions with simulated versions, known as mock objects. These mock objects mimic the behavior of their real counterparts, allowing developers to isolate components under test from their dependencies. Mocks are programmable and can be configured to return predefined values, raise exceptions, or record interactions.
Key Concepts of Mocking:
- Mock Objects: Mock objects are objects that simulate the behavior of real objects. They can be configured to behave in specific ways and record interactions with them.
- Patch: Patching is a technique used to replace objects or functions in the code under test with mock objects. This allows developers to control the behavior of dependencies during testing.
- Assertions: Assertions in unit tests verify that certain conditions are met. Mocks can be used in assertions to verify that specific methods were called with the expected arguments or to check the number of times a method was called.
Using Mocking in Python's Unittest:
Python's unittest.mock
module provides a flexible framework for creating and working with mock objects. Developers can use the patch()
function to replace objects or functions with mock equivalents temporarily. Additionally, assertions such as assert_called_once_with()
and assert_called_with()
can be used to verify the behavior of mock objects.
Advantages of Mocking:
- Isolation: Mocking enables the isolation of code under test, facilitating focused testing without reliance on external dependencies.
- Flexibility: Mock objects offer flexibility in configuring behaviors, allowing developers to simulate various scenarios and edge cases effortlessly.
- Speed: Mocking can expedite testing by eliminating the need to interact with external systems or resources, resulting in faster test execution times.
- Enhanced Test Coverage: Mocking empowers developers to test error-handling scenarios and exceptional conditions that may be challenging to reproduce with real dependencies.
Limitations of Mocking:
- Complexity: Overuse of mocking can lead to overly complex test suites, diminishing readability and maintainability.
- Dependency on Implementation: Mocks are tightly coupled to the implementation details of the code under test, making tests susceptible to breaking when implementation changes occur.
- Risk of False Positives: Inadequate verification of mock behavior may result in false positives, where tests pass despite incorrect implementations or missing assertions.
Best Practices for Effective Mocking:
- Focused Testing: Prioritize testing the behavior of the code under test rather than the implementation details of dependencies.
- Clear Documentation: Document the purpose and behavior of mock objects to improve code understanding and facilitate collaboration among team members.
- Regular Review: Periodically review mock usage to ensure tests remain relevant, maintainable, and aligned with evolving codebases.
Example:
Suppose you have a function in your application like the following, which communicates with an external API to retrieve data:
import requests
def get_data_from_api(url):
response = requests.get(url)
if response.status_code == 200:
return response.json()
else:
return None
In testing, you want to verify that the get_data_from_api()
function handles situations correctly when the API returns data successfully and when it encounters errors. However, actually calling the API during testing may cause issues such as: time consumption, dependency on network connection, or error-prone behavior.
Instead of making actual calls to the API, you can use the Mocking technique to create a mock object, simulating the API's behavior during testing. Here's an example of how to do this in unittest:
import unittest
from unittest.mock import patch
from my_module import get_data_from_api
class TestGetDataFromAPI(unittest.TestCase):
@patch('my_module.requests.get')
def test_get_data_success(self, mock_get):
mock_get.return_value.status_code = 200
mock_get.return_value.json.return_value = {'data': 'test'}
data = get_data_from_api('http://example.com/api')
self.assertEqual(data, {'data': 'test'})
@patch('my_module.requests.get')
def test_get_data_failure(self, mock_get):
mock_get.return_value.status_code = 404
data = get_data_from_api('http://example.com/api')
self.assertIsNone(data)
if __name__ == '__main__':
unittest.main()
@patch
decorator to replace the requests.get
function with a mock object. In each test case, we set the expected return values of the mock object (e.g., status_code
and json
), thereby testing whether the get_data_from_api()
function works correctly in both successful and failed cases.
Conclusion:
Mocking is a valuable technique in unit testing that enables developers to create reliable and maintainable test suites. By leveraging the capabilities of Python's unittest.mock
module, developers can effectively simulate the behavior of dependencies and external systems, leading to more robust and efficient testing practices.
References:
What have you gained from the software tester job?
You often hear about what you need to learn to become a tester, but have you ever wondered what you will learn when you are a tester? Besides enhancing specialized skills such as software testing, requirement analysis, and staying updated on new technologies, you can also improve some useful knowledge and skills in life as follows:
- Deep Understanding of Various Business Domains:
This is truly interesting because few professions can help you understand another industry's business so thoroughly. As a tester in software project, you have the opportunity to read all customer requirements, understand the project's detailed design, and thus comprehend the activities, processes, or specific requirements of a particular organization or industry. While developers may only understand a part of the functionality which they are responsible for. Due to job demands, testers must learn more about the context, operational environment, end-users behavior, security issues, and compliance of the field they are testing in. Therefore, testers accumulate knowledge about various business domains such as banking, logistics, ERP, etc.
Furthermore, because testers test all function of the product, they will have a deep understanding of how business operations are reflected in a software product. They know exactly how real-world data flows will be stored and processed within the software system.
Imagine after testing a material management software system for a manufacturing factory, you will know how the material ordering process works, how purchased materials are categorized and stored, how to calculate the quantity of materials for each production line, how to calculate inventory, and the appropriate time to reorder new materials... You may even understand the production process better than an employee of that factory. This is amazing!
- Improving Communication Skills:
In the world of developing a software product, developers are builders; they create code that makes everything work. Testers are detectives; they verify the correctness of the product, accompanied by a list of errors that developers need to fix. It is frustrating to be pointed out errors and have to fix them; especially those not mentioned in the design but must be done according to the tester's suggestion. Therefore, testers and developers are often seen as two opposing sides.
When starting out as a tester, it is hard to avoid arguments and conflicts. However, over times, to persuade and prevent arguments with developers, testers practice the ability to express opinions, provide feedback, and report clearly, understandably, and convincingly. They also learn to listen, share information, exchange ideas, and resolve conflicts constructively. This significantly improves their communication and persuasive skills.
- Viewing Problems from Various Perspectives:
To ensure that the testing process is comprehensive and reliable, throughout the work, testers must test the product from various perspectives. As a good tester, you not only test what is mentioned in the design but also have to stand from the end-user's perspective to think whether your software is user-friendly, helps them operate faster... You not only test the software when it operates under good conditions but also test it under poor conditions. You need to create various test scenarios. This helps you develop a multidimensional mindset for solving different life problems.
In summary, as a tester, you not only contribute to the development of software, bring many useful experiences for end-users but also learn and improve many good skills for your life.
Image source:
https://www.freepik.com/free-vector/disruptive-education-globe-background-vector-geography-digital-remix_17213285.htm#fromView=search&page=1&position=26&uuid=33b4ecf5-cd4b-4d6d-b917-6213ca1bf6d7
https://www.freepik.com/free-vector/flat-design-erp-illustration_25561035.htm#fromView=search&page=1&position=8&uuid=ebbdf32b-5bf8-433d-a85e-8dc413076bdd
https://www.freepik.com/free-photo/representation-user-experience-interface-design_94963704.htm#fromView=search&page=2&position=29&uuid=4ef0f53a-05c6-42d4-adda-7102f1ac25b2
https://www.freepik.com/free-photo/programmers-questioning-source-cyber-attacks-system-security-coverage-software-technician-triangulates-hacker-location-by-updating-safety-script-codes-data-processor-sequencer_25474009.htm#fromView=search&page=1&position=24&uuid=c8164e4a-0cb7-41c8-9492-953b98fbb71d
Some array sorting issues and solutions in ReactJS
To sort the data array, we can use many methods. Incorrect selection can lead to errors that are difficult to detect with uniform, standard-format test data. I would like to share some errors and solutions that I have encountered in a React project, as follows:
What is Google Cloud Search ?
Your company is using Google Workplace, You have many information in Gmail, Google Drive, Google Calendar, Google Contacts and others alike. Suddenly, you remember you need to find some information, and you don't remember where that information is in Google Workplace. Google Cloud Search is is what you need in this case.