Implementing Test Case Detail Retrieval with MyBatis resultMap and TypeHandler
Despite pandemic‑induced remote work challenges, the author details progress on implementing test case management, focusing on MyBatis resultMap usage, bean and database design complexities, and provides the full XML mapping and SQL query for retrieving detailed test case information.
Due to the pandemic, the author has been working from home since Monday, noticing a significant impact on work efficiency. The plan was to finish writing test cases today and start on the test case set module in the next two days, with eleven interfaces remaining.
After fixing many issues last week, today went smoothly, but dealing with various beans and database table designs consumed a lot of time, leading to a headache by six in the evening and a break for dinner. The current progress suggests that completing development by next Monday is feasible.
The key technical point learned is the use of resultMap in mybatis. While map and type share many similarities, map adds an extra mapping layer that can associate different object properties with table columns, allowing the configuration of appropriate typeHandler s.
Editing test cases is divided into two parts: attributes, especially related attributes, and test data, both of which are tied to the request.
Requirement Diagram
The diagram below shows the test case detail view, with the left side displaying some related attribute information. This interface is read‑only; the header and upstream parameters are implemented as shown in the second diagram, requiring handling of hierarchical structures and parameter attributes (such as required flags and types). The data needs to be stored, but the exact structure is not yet available, representing a current challenge.
Query Test Case Data Details
<resultMap type="com.okay.family.common.bean.testcase.response.CaseDetailBean" id="CaseDetailBean">
<result property="id" column="id"/>
<result property="envId" column="envId"/>
<result property="envName" column="envName"/>
<result property="apiId" column="apiId"/>
<result property="apiName" column="apiName"/>
<result property="httptype" column="method"/>
<result property="serviceId" column="serviceId"/>
<result property="serviceName" column="serviceName"/>
<result property="moduleId" column="moduleId"/>
<result property="moduleName" column="moduleName"/>
<result property="readType" column="type"/>
<result property="url" column="path"/>
<result property="name" column="name"/>
<result property="header" column="headersmoco" typeHandler="com.okay.family.common.typehandler.JsonArrayHandler"/>
<result property="upData" column="paramsmoco" typeHandler="com.okay.family.common.typehandler.JsonArrayHandler"/>
<result property="testWish" column="verify" typeHandler="com.okay.family.common.typehandler.ListCaseVerifyBeanHandler"/>
</resultMap>
<select id="getCaseDetail" parameterType="java.lang.Integer" resultMap="CaseDetailBean">
select c.id,c.name,c.apiId,a.name apiName,c.envId,e.name envName,c.serviceId,s.name
serviceName,c.moduleId,m.name moduleName,c.type,c.method,c.headersmoco,c.paramsmoco,c.verify,c.path from
<include refid="table"/> c left join
<include refid="env"/> e on c.envId = e.id left join
<include refid="service_table"/> s on c.serviceId = s.id left join
<include refid="module_table"/> m on c.moduleId = m.id left join
<include refid="api_info"/> a on c.apiId = a.id
WHERE c.id = #{0}
</select>Contact information for the FunTester public account is provided, encouraging readers to follow and prohibiting unauthorized reposting.
Additional links to popular articles, such as API testing collections, performance testing topics, HTTP mind maps, programming mindset articles, Java performance guide recommendations, Selenium parallel testing best practices, UI testing plans, and software testing outsourcing, are listed for further reading.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
