ratingE-Commerce

Mock Jutsu HOW-TO | UK

The rating function within the mock-jutsu library is a specialised tool designed for developers and QA engineers working in the e-commerce sector. It generates realistic product scores on a scale from 1.0 to 5.0, providing the essential mock data needed to simulate user feedback and customer satisfaction levels. By leveraging mock-jutsu, teams can avoid the tedious task of manual data entry, instead populating their applications with standardised numerical values that accurately reflect real-world consumer behaviour and market trends.

Technically, the function employs a precise algorithm to produce floating-point numbers rounded to a single decimal place, such as 4.5 or 3.2. This ensures that the generated test data adheres to the common UI patterns found on major global retail platforms. The consistency of this output is vital for developers who need to verify that their frontend components, such as dynamic star-rating widgets or review summary cards, render correctly across various screen sizes and resolutions. Using mock-jutsu ensures that your staging environment remains populated with high-fidelity information throughout the entire development lifecycle.

In practical testing scenarios, the rating function is indispensable for validating complex business logic, such as search result ranking or recommendation engine filters. For example, you can use this mock data to test if your "Top Rated" filter correctly prioritises a 4.9 score over a 4.2. It also allows for rigorous edge-case testing, ensuring the system gracefully handles the minimum score of 1.0 or the maximum of 5.0 without breaking the layout. By automating these inputs, developers can focus on refining their sorting algorithms rather than worrying about the integrity of their underlying data sets.

Mock-jutsu provides exceptional flexibility for integrating this function into existing workflows. Developers can generate values directly from the command line using the command mockjutsu generate rating or via the Python API with jutsu.generate('rating'). Furthermore, for those conducting performance testing, the JMeter function ${__mockjutsu(rating,)} allows for the seamless injection of scores into load-testing scripts. This multi-platform support ensures that whether you are writing unit tests or conducting full-scale system simulations, you have access to high-quality, reliable data at every stage of the software delivery process.

CLI Usage
mockjutsu generate ratingmockjutsu bulk rating --count 10mockjutsu export rating --count 10 --format jsonmockjutsu export rating --count 10 --format csvmockjutsu export rating --count 10 --format sql
Python API
from mockjutsu import jutsujutsu.generate('rating')jutsu.bulk('rating', count=10)jutsu.template(['rating'], count=5)
JMeter
${__mockjutsu_ecommerce(rating)}# JMeter Function: __mockjutsu_ecommerce# Parameter 1: rating# Parameter 2: (not required for this function)
REST API
GET /generate/rating# → {"type":"rating","result":"...","status":"ok"}GET /bulk/rating?count=10POST /template {"types":["rating"],"count":1}

Other Languages