Build a DeepSeek API intelligent testing engine in 8 minutes: before the coffee is cold, the test report is ready

Written by
Iris Vance
Updated on:July-13th-2025
Recommendation

Quickly build an intelligent testing engine, enjoy your work, and protect your hairline.

Core content:
1. Comparison of the pain points of traditional API testing and the advantages of intelligent testing engines
2. The construction process and demonstration of DeepSeek-R1 intelligent testing engine
3. The "magic list ingredients" required by the intelligent testing engine and how to use them

Yang Fangxian
Founder of 53AI/Most Valuable Expert of Tencent Cloud (TVP)
I recently finished the development of Jira cloud xray SDK, and I have a little free time. I will share a scenario of LLM fully automated API testing after get off work, hoping to inspire others to use it at home (factory). I believe many people feel the same way. In the past, many people spent thousands of dollars (of course, the company's money) to attend AI conferences, but most of the time they just listened to them in vain. The lectures on LLM empowerment testing that I attended were basically just for fun, and it was difficult to apply them to my own home. The 8-minute series strives to be ready to use out of the box. LLM that can be used by all test engineers is a good LLM, focusing on enjoying work and protecting hairline.
1. Prologue: When "Artificial Idiot" Meets "Artificial Intelligence and Courage"

"Xiao Wang, have you finished writing the exception test cases for this order interface?" "Boss, I just tested the 38th scenario and my computer blue screened..." "What's your test coverage?" "About... an area the size of a coffee cup?"


This classic conversation reveals the three major pain points of traditional API testing: the hair of test engineers is getting thinner , the coffee is getting more bitter, and the test coverage is always like Schrödinger's cat - tested but not fully tested. But today, I want to share a small experiment of mine: to exaggerate, the intelligent testing engine built with DeepSeek-R1 can complete the whole process automation from test design to execution in the time it takes you to finish a cup of coffee (or even before the coffee cools down)!

Let's take a look at the demo first. The platform designs and executes fully automated tests for an API that returns cities based on zip codes.

api.zippopotam.us, we can see that it requires almost no physical effort, and most importantly, it hardly causes hair loss.


2. Speedy Construction: 8-minute cooking test of the Manchu-Han Banquet


2.1 Ingredients preparation (0-2 minutes)

Just like boiling water is needed to cook instant noodles, our smart test kitchen needs:

Many people have asked me in private messages before that the json returned by LLM is sometimes loaded

I can't come out. Today I will share a secret weapon with you.

The main feature is one-use-one-silent-json_repair

# List of magic ingredients
import  streamlit  as  st   # Visualize the pan
import  requests          # Network induction cooker
from  json_repair  import  repair_json   # JSON repair shovel

At this time, your computer will say: "Master, we have detected that you want to save your hairline, and have automatically blocked all social software."

2.2 Core recipe (2-5 minutes)

Our secret weapon is this "test chef":

class DeepSeekTestGenerator : 
    def generate_tests ( self ,  api_desc : str ) - > dict :
        # The spell to summon the test dragon is hidden here
        payload  = {
            "model" : "deepseek-r1" ,
            "messages" : [
                { "role" : "system" , "content" :  self . system_prompt } ,
                { "role" : "user" , "content" :  api_desc }
            ] ,
            "temperature" : 0.3 # Control the chef's "temperature"
        }


This class is like the legendary kitchenware in "The Cooking Master Boy". You give it an API description and it spits out:

  • Normal scene test (as gentle as an old lady crossing the road)
  • Boundary value testing (as tricky as Party A changing requirements)
  • Abnormal parameter testing (as creative as a programmer writing bugs)

2.3 Automated assembly line (5-8 minutes)

The test execution engine is a tireless "test madman":

Python

class TestExecutor : 
    def execute_test ( self ,  test_case : dict ) - > dict :
        try :
            # There are millions of requests per second.
            response  =  requests . request (
                method = test_case [ "method" ] ,
                url = f" { self . base_url } { test_case [ 'path' ] } " ,
                params = test_case . get ( "params" ) ,
                timeout = 5
            )
            # Automatic diagnostic report generation system
            passed_assertions . append ( {
                "type" :  assertion [ "type" ] ,
                "passed" :  passed ,
                "expected" :  assertion . get ( "expect" ) ,
                "actual" :  response . status_code
            } )

How powerful is this engine? While performing the test, it can:

  1. Monitor response time (accurate to milliseconds)
  2. Automatically verify JSON data structure (more detailed than mother-in-law checking household registration)
  3. Generate visual reports (better than beauty cameras in showing advantages)

3. Black Technology Dissection Room: The Nine Yang Magic Skill of Code


3.1 Reinforcement Learning Test Generation (Turing Possession)

Our prompt design has a hidden meaning:

Python

system_prompt  = """As an API testing expert, please generate a test suite according to the following requirements: 
1. Include normal/boundary/abnormal scenarios
2. Verify the response using JSON Path
3. Include performance assertions (response time < 800ms)
4. Output OpenAPI 3.0 specification"""

This is equivalent to installing a "test personality chip" in AI, allowing it to instantly have:

  • Ten-year testing veteran's scene coverage capabilities
  • Sherlock Holmes's Intuition for Discovering the Abnormal
  • Performance Requirements for Olympic Sprinters

3.2 Self-healing JSON processing (medical miracle)

return json.loads(repair_json(response.json()["choices"][0]["message"]["content"]))

thisrepair_jsonLike an "ER doctor" in the testing world, it can:

  • Automatically fix missing quotes (cure OCD)
  • Braces to correct misalignment (orthopedic precision)
  • Dealing with encoding issues (comparable to simultaneous interpretation)

3.3 Intelligent Assertion Engine (Judge Protocol)

if  assertion [ "type" ] == "json_path" :  
    passed  =  self . _validate_json_path ( response . json ( ) ,  assertion )

This assertion system is as strict as a college entrance examination examiner:

  • Check if the data exists ("Where's your ID? Take it out and let me see!")
  • Verify data type ("Why did the string become a number?")
  • Check data range ("Age 200? Are you a vampire?")

4. Visual battlefield: a fashion show of test results


While traditional test reports are still written in Word documents, our system has already started a "Data Fashion Week":

with  st . expander ( "view details" ) :
    col1 ,  col2  =  st . columns ( 2 )
    with  col1 :
        st . metric ( "response time" , f " { response_time : .2f } ms" ) 
        st . write ( "### Assertion result" )
        for  assertion  in  assertions :
            icon  = "✅" if  passed  else "❌"   
    with  col2 :
        st . json ( response_sample )


This interface can:

  • Use a traffic light system to display test results (more intuitive than traffic lights)
  • Display real-time response data (as instant as live streaming)
  • Generate interactive charts (more professional than stock candlestick charts)

5. Future Outlook: Test Engineers' "Slacking Off" Plan


When this system is complete (currently just a simple POC):

  1. The daily routine of a test engineer will become: drink coffee → look at the dashboard → click the "retest" button → continue drinking coffee
  2. CI/CD pipeline will be truly "driverless", and Git commits will trigger intelligent testing
  3. Humans can finally be freed from repetitive work and focus on more important tasks - writing comments for test cases written by AI