KR20230016322A - Method and system for extracting fine-grained traceability links between API document comments and test code lines - Google Patents

Method and system for extracting fine-grained traceability links between API document comments and test code lines Download PDF

Info

Publication number
KR20230016322A
KR20230016322A KR1020210097630A KR20210097630A KR20230016322A KR 20230016322 A KR20230016322 A KR 20230016322A KR 1020210097630 A KR1020210097630 A KR 1020210097630A KR 20210097630 A KR20210097630 A KR 20210097630A KR 20230016322 A KR20230016322 A KR 20230016322A
Authority
KR
South Korea
Prior art keywords
code
test
sentence
extracting
unit
Prior art date
Application number
KR1020210097630A
Other languages
Korean (ko)
Other versions
KR102567407B1 (en
Inventor
홍신
김지웅
Original Assignee
한동대학교 산학협력단
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 한동대학교 산학협력단 filed Critical 한동대학교 산학협력단
Priority to KR1020210097630A priority Critical patent/KR102567407B1/en
Publication of KR20230016322A publication Critical patent/KR20230016322A/en
Application granted granted Critical
Publication of KR102567407B1 publication Critical patent/KR102567407B1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/169Annotation, e.g. comment data or footnotes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/75Structural analysis for program understanding

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Machine Translation (AREA)

Abstract

The present invention relates to a method and system for extracting the correlation between API documents and test codes. The present invention relates to a method for extracting the correlation between API documents and test codes, which may include the steps of: segmenting the API document into sentence units by a sentence segmentation portion; segmenting the test code into single semantic sections by a code segmentation portion; receiving electroencephalogram data from a plurality of measuring electrodes by a receiving portion; and, extracting, by a correlation extraction portion, the correlation between the sentence segmented in the sentence segmentation portion and the code section segmented in the code segmentation portion.

Description

API 문서와 테스트 코드간 연관성 추출 방법 및 시스템{Method and system for extracting fine-grained traceability links between API document comments and test code lines} Method and system for extracting fine-grained traceability links between API document comments and test code lines}

본 발명은 API 문서와 테스트 코드간 연관성 추출 방법 및 시스템에 관한 것으로, 특히 구문적 유사도를 통해 동일한 요구사항을 표현한 API문서와 테스트코드간의 관계를 문장 및 코드라인 단위로 추출하여 문서와 테스트 코드의 품질 평가 등에 활용이 가능한 API 문서와 테스트 코드간 연관성 추출 방법 및 시스템에 관한 것이다.The present invention relates to a method and system for extracting a correlation between an API document and a test code, and in particular, extracts the relationship between an API document and a test code expressing the same requirements through syntactic similarity in units of sentences and code lines to extract the relationship between the document and the test code. It relates to a method and system for extracting correlation between API documents and test codes that can be used for quality evaluation.

SW 프로젝트에서 자연어로 기술된 API문서와 API용례를 코드로 작성한 테스트 케이스를 통해 기능 요구사항이 부분적으로 작성되고 관리되고 있다. In SW projects, functional requirements are partially written and managed through API documents written in natural language and test cases written with API usage codes.

따라서, API문서에 내포된 요구사항을 테스트 오라클로 도출하고 관리하기 위해서는 문서와 테스트케이스 코드 간의 연관관계가 추적되어야 하는데, 추적이 불가능할 경우, API 문서 변경에 따른 테스트케이스와 요구사항 명세가 불일치하는 문제가 발생하거나, API문서에 작성된 요구사항 자체가 테스트 케이스에서 누락되는 문제가 발생할 수 있다.Therefore, in order to derive and manage the requirements contained in the API document with a test oracle, the relationship between the document and the test case code must be traced. Problems may occur or requirements written in API documents may be omitted from test cases.

관련 선행기술로는 대한민국 등록특허 10-2002545호 "가상화를 통한 코드 테스트 수행 자동화 방법 및 장치"가 있으나 반복되는 소프트웨어 검증을 위한 테스트를 가상화 환경에서 자동 수행되도록 제어하는 기술을 개시하고 있을 뿐이다.As a related prior art, there is Korean Patent Registration No. 10-2002545 entitled "Method and Apparatus for Automating Code Test Execution through Virtualization", but only discloses a technique for controlling repeated software verification tests to be automatically performed in a virtualization environment.

본 발명이 해결하고자 하는 과제는 API문서와 테스트코드간의 관계를 문장 및 코드라인 단위로 추출하여 문서와 테스트 코드의 품질 평가가 가능한 API 문서와 테스트 코드간 연관성 추출 방법을 제공하는 것에 있다.An object to be solved by the present invention is to provide a method for extracting a relationship between an API document and a test code that can evaluate the quality of the document and the test code by extracting the relationship between the API document and the test code in units of sentences and code lines.

본 발명의 API 문서와 테스트 코드간의 연관성을 추출하는 방법은, 문장분절부가 API문서를 문장 단위로 분절하는 단계와, 코드분절부가 테스트코드를 단일의미구간으로 분절하는 단계와, 연관관계추출부가 문장분절부에서 분절된 문장과 코드분절부에서 분절된 코드구간간의 연관관계를 추출하는 단계를 포함한다.The method of extracting the association between the API document and the test code of the present invention includes the step of segmenting the API document into sentence units by the sentence segmentation unit, the step of segmenting the test code by the code segmentation unit into single semantic sections, and the step of segmenting the test code into single semantic sections by the code segmentation unit. and extracting a relation between a sentence segmented in the segmentation unit and a code section segmented in the code segmentation unit.

본 발명의 연관성추출서버와 사용자단말로 구성된 API 문서와 테스트 코드간의 연관성을 추출하는 시스템은, API문서를 문장 단위로 분절하는 문장분절부와, 테스트코드를 단일의미구간으로 분절하는 코드분절부와, 상기 문장분절부에서 분절된 문장과 상기 코드분절부에서 분절된 코드구간간의 연관관계를 추출하는 연관관계추출부를 포함하고, 상기 연관관계추출부는 테스트 대상 메소드와 테스트 메소드를 메소드 단위로 매칭하는 메소드단위매칭모듈과, 메소드 단위로 매칭된 테스트 대상 메소드의 문장과 테스트 메소드의 코드구간 사이의 유사도를 계산하는 유사도계산모듈을 포함한다.The system for extracting the correlation between the API document and the test code composed of the correlation extraction server and the user terminal of the present invention includes a sentence segmentation unit that segments the API document in sentence units, a code segmentation unit that segments the test code into single semantic sections, and , a correlation extraction unit for extracting a relationship between a sentence segmented in the sentence segmentation unit and a code section segmented in the code segmentation unit, wherein the association relationship extraction unit is a method for matching the test method and the test method on a method-by-method basis. It includes a unit matching module and a similarity calculation module that calculates the similarity between the code section of the test method and the sentence of the method to be tested matched on a method by method basis.

본 발명에 의하면, API문서와 테스트 코드간의 구문적 유사도 계산을 통해 동일한 요구사항을 표현하는 관계를 추출하고, 추출된 연관관계를 바탕으로 API문서와 테스트코드의 품질 확인이 가능하다.According to the present invention, it is possible to extract a relationship expressing the same requirement through syntactic similarity calculation between an API document and a test code, and to check the quality of the API document and the test code based on the extracted relationship.

또한, API문서의 주석에 링크를 삽입하여 API문서를 보강할 수 있고, 누락된 요구사항을 확인하여 누락된 주석을 보완할 수 있고, 코드리뷰를 보조가 가능하다.In addition, API documentation can be supplemented by inserting a link in the comments of the API documentation, missing requirements can be checked and the missing comments can be supplemented, and code review can be assisted.

또한, 누락 사항 혹은 의미 불일치 사항을 추정하여 사용자에게 경보를 발생시킴으로써 테스트 품질 문제를 사전에 방지하는 효과가 있다. In addition, it is effective in preventing test quality problems in advance by estimating omissions or semantic inconsistencies and generating an alarm to the user.

도 1은 본 발명의 실시예에 따른 API 문서와 테스트 코드간 연관성 추출 방법을 설명하는 흐름도이다.
도 2는 본 발명의 실시예에 따른 연관관계추출부의 연관관계 추출 방법을 설명하는 흐름도이다.
도 3은 본 발명의 실시예에 따른 API 문서와 테스트 코드간 연관성 추출 시스템을 설명하는 구성도이다.
도 4는 본 발명의 실시예에 따른 메소드단위 매칭모듈의 매칭 방법을 설명하는 예시도이다.
도 5는 본 발명의 실시예에 따른 유사도계산 모듈의 유사도 계산 방법을 설명하는 예시도이다.
도 6은 본 발명의 실시예에 따른 매칭모듈이 매칭하는 방법을 설명하는 예시도이다.
도 7 내지 도 10은 본 발명의 실시예에 따른 실험 결과를 나타내는 테이블이다.
도 11 및 도 13은 본 발명의 실시예에 따른 추출한 연관관계를 활용하는 예시도이다.
1 is a flowchart illustrating a method for extracting a correlation between an API document and a test code according to an embodiment of the present invention.
2 is a flowchart illustrating a method of extracting a relational relation of a relational relation extracting unit according to an embodiment of the present invention.
3 is a configuration diagram illustrating a system for extracting a relationship between an API document and a test code according to an embodiment of the present invention.
4 is an exemplary view illustrating a matching method of a method unit matching module according to an embodiment of the present invention.
5 is an exemplary view illustrating a similarity calculation method of a similarity calculation module according to an embodiment of the present invention.
6 is an exemplary view illustrating a matching method by a matching module according to an embodiment of the present invention.
7 to 10 are tables showing experimental results according to an embodiment of the present invention.
11 and 13 are exemplary diagrams of utilizing extracted correlations according to an embodiment of the present invention.

본 명세서에 개시되어 있는 본 발명의 개념에 따른 실시 예들에 대해서 특정한 구조적 또는 기능적 설명은 단지 본 발명의 개념에 따른 실시 예들을 설명하기 위한 목적으로 예시된 것으로서, 본 발명의 개념에 따른 실시 예들은 다양한 형태들로 실시될 수 있으며 본 명세서에 설명된 실시 예들에 한정되지 않는다.Specific structural or functional descriptions of the embodiments according to the concept of the present invention disclosed in this specification are only illustrated for the purpose of explaining the embodiments according to the concept of the present invention, and the embodiments according to the concept of the present invention It can be embodied in various forms and is not limited to the embodiments described herein.

본 발명의 개념에 따른 실시 예들은 다양한 변경들을 가할 수 있고 여러 가지 형태들을 가질 수 있으므로 실시 예들을 도면에 예시하고 본 명세서에서 상세하게 설명하고자 한다. 그러나 이는 본 발명의 개념에 따른 실시 예들을 특정한 개시 형태들에 대해 한정하려는 것이 아니며, 본 발명의 사상 및 기술 범위에 포함되는 모든 변경, 균등물, 또는 대체물을 포함한다.Embodiments according to the concept of the present invention can apply various changes and have various forms, so the embodiments are illustrated in the drawings and described in detail in this specification. However, this is not intended to limit the embodiments according to the concept of the present invention to specific disclosure forms, and includes all changes, equivalents, or substitutes included in the spirit and technical scope of the present invention.

본 명세서에서 사용한 용어는 단지 특정한 실시 예를 설명하기 위해 사용된 것으로서, 본 발명을 한정하려는 의도가 아니다. 단수의 표현은 문맥상 명백하게 다르게 뜻하지 않는 한, 복수의 표현을 포함한다. 본 명세서에서, "포함하다" 또는 "가지다" 등의 용어는 본 명세서에 기재된 특징, 숫자, 단계, 동작, 구성 요소, 부분품 또는 이들을 조합한 것이 존재함을 지정하려는 것이지, 하나 또는 그 이상의 다른 특징들이나 숫자, 단계, 동작, 구성 요소, 부분품 또는 이들을 조합한 것들의 존재 또는 부가 가능성을 미리 배제하지 않는 것으로 이해되어야 한다.Terms used in this specification are used only to describe specific embodiments, and are not intended to limit the present invention. Singular expressions include plural expressions unless the context clearly dictates otherwise. In this specification, terms such as "comprise" or "having" are intended to indicate that there is a feature, number, step, operation, component, part, or combination thereof described in this specification, but one or more other features It should be understood that it does not preclude the possibility of the presence or addition of numbers, steps, operations, components, parts, or combinations thereof.

이하, 본 명세서에 첨부된 도면들을 참조하여 본 발명의 실시 예들을 상세히 설명한다.Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings.

도 1은 본 발명의 실시예에 따른 API 문서와 테스트 코드간 연관성 추출 방법을 설명하는 흐름도이다.1 is a flowchart illustrating a method for extracting a correlation between an API document and a test code according to an embodiment of the present invention.

도 1을 참조하면, API 문서와 테스트 코드간의 연관성을 추출하는 방법은 문장분절부가 API문서를 문장 단위로 분절한다(S101). 문장분절부는 구체적 연관관계를 추출하기 위해 단일요구사항으로 분절하며, 마침표, 공백 행과 태그(@return)에서 분절을 하나 이에 대해 한정하는 것은 아니며, 문장 단위를 분절하는 다양한 휴리스틱이 활용될 수 있다. Referring to FIG. 1 , in the method of extracting the association between the API document and the test code, the sentence segmentation unit segments the API document in units of sentences (S101). The Sentence Segmentation Unit is segmented as a single requirement to extract specific relationships, and segmentation is performed at periods, blank lines, and tags (@return), but is not limited thereto. Various heuristics for segmenting sentence units can be used. .

코드분절부가 테스트코드를 단일의미구간으로 분절한다(S103). 코드분절부는 기대동작을 확인하는 구문을 기준으로 분절할 수 있다. 코드분절부는 기대 동작을 확인하는 구문이 try문 안에 존재할 경우 catch문도 함께 실행되는 특징에 따라 try-catch문 전체를 하나로 분절할 수 있다. 코드분절부가 분절한 구문의 값에 영향을 주는 데이터/흐름 의존성 구문만 포함하여 단일 의미 구간으로 나타낸다. 이 때 데이터/흐름 의존성 정보 활용 이외의 다른 방법이 단일 의미 구간을 판별하는 방식도 활용될 수 있다.The code segmentation unit segments the test code into single semantic sections (S103). The code segmentation unit may be segmented based on a syntax for confirming an expected operation. The code segmentation unit can segment the entire try-catch statement into one according to the characteristic that the catch statement is also executed when the statement confirming the expected operation exists in the try statement. It is represented as a single semantic section including only the data/flow dependent phrases that affect the value of the phrase segmented by the code segment. At this time, a method other than the use of data/flow dependency information may be used to determine a single semantic section.

즉, 문장분절부에서 API문서를 문장 단위로 분절하고, 코드분절부가 테스트코드를 단일의미구간으로 분절하여 기존의 메소드 단위로 추출 및 추적하는 기법의 한계를 해결할 수 있다.That is, the sentence segmentation unit segments the API document into sentence units, and the code segmentation unit segments the test codes into single semantic sections, thereby solving the limitations of the existing technique of extracting and tracing in units of methods.

연관관계추출부가 문장분절부에서 분절된 문장과 코드분절부에서 분절된 코드구간간의 연관관계를 추출한다(S105). 추출된 연관관계를 제공부에 제공하고 제공부가 추출된 연관관계를 사용자단말에 제공한다(S107). 사용자단말은 제공받은 연관관계를 통해 API문서의 주석에 링크를 삽입하여 API문서를 보강할 수 있고, 누락된 요구사항을 확인하여 누락된 주석을 보완할 수 있고, 코드리뷰를 보조할 수 있다. 또한 누락 사항 혹은 의미 불일치 사항을 추정하여 사용자에게 경보를 발생시킴으로써 테스트 품질 문제를 사전에 방지하는 데 활용될 수 있다.The association relation extraction unit extracts a relation between the sentence segmented in the sentence segmentation unit and the code section segmented in the code segmentation unit (S105). The extracted relationship is provided to the provider and the provider provides the extracted relationship to the user terminal (S107). The user terminal can reinforce the API document by inserting a link in the annotation of the API document through the provided relationship, supplement the missing annotation by checking the missing requirement, and assist in code review. In addition, it can be used to prevent test quality problems in advance by estimating omissions or semantic inconsistencies and generating alerts to users.

도 2는 본 발명의 실시예에 따른 연관관계추출부의 연관관계 추출 방법을 설명하는 흐름도이다.2 is a flowchart illustrating a method of extracting a relational relation of a relational relation extracting unit according to an embodiment of the present invention.

도 2를 참조하면, 연관관계추출부는 메소드단위매칭모듈, 유사도계산모듈, 매칭모듈, 추출모듈로 구성되고, 메소드단위매칭모듈이 테스트 대상 메소드와 테스트 메소드를 메소드 단위로 매칭한다(S201). 유사도계산모듈이 메소드 단위로 매칭된 테스트 대상 메소드의 문장과 테스트 메소드의 코드구간 사이의 유사도를 계산한다(S203).Referring to FIG. 2 , the association relation extraction unit is composed of a method unit matching module, a similarity calculation module, a matching module, and an extraction module, and the method unit matching module matches the test target method and the test method in a method unit (S201). The similarity calculation module calculates the similarity between the matched sentence of the test target method and the code section of the test method on a method basis (S203).

매칭모듈이 계산된 구문적유사도를 이용하여 문장과 코드구간을 매칭한다(S205). 구문적 유사도는 소스코드의 이름(identifier)과 상수 값 등을 구문적 요소를 바탕으로 한 IF-IDF를 이용하여 유사도를 측정할 수 있으며, 이외에도 구문 간 유사도를 측정하는 다양한 기법이 활용될 수 있다. The matching module matches sentences and code sections using the calculated syntactic similarity (S205). Syntactic similarity can be measured using IF-IDF based on syntactic elements such as the name (identifier) and constant value of the source code. In addition, various techniques for measuring similarity between syntaxes can be used. .

추출모듈이 연관관계를 갖는 문장과 코드구간 쌍을 추출한다(S207). 추출모듈이 측정한 구문적 유사도를 통해서 동일한 요구사항을 표현한 것으로 보이는 문장과 코드 요소의 쌍을 연관관계로 추출한다.The extraction module extracts a pair of related sentences and code sections (S207). Through the syntactic similarity measured by the extraction module, pairs of sentences and code elements that appear to express the same requirements are extracted as associations.

도 3은 본 발명의 실시예에 따른 API 문서와 테스트 코드간 연관성 추출 시스템을 설명하는 구성도이다.3 is a configuration diagram illustrating a system for extracting a relationship between an API document and a test code according to an embodiment of the present invention.

도 3을 참조하면, API 문서와 테스트 코드간 연관성 추출 시스템(10)은 연관성추출서버(100)와 사용자단말(200)로 구성된다.Referring to FIG. 3 , the correlation extraction system 10 between API documents and test codes is composed of a correlation extraction server 100 and a user terminal 200 .

연관성추출서버(100)는 문장분절부(110), 코드분절부(120), 연관관계추출부(130), 제공부(140), 통신부(150), 제어부(160)로 구성된다.The association extraction server 100 is composed of a sentence segmentation unit 110, a code segmentation unit 120, a relationship extraction unit 130, a provision unit 140, a communication unit 150, and a control unit 160.

문장분절부(110)는 API문서를 문장 단위로 분절할 수 있다. 문장분절부(110)는 구체적 연관관계를 추출하기 위해 단일요구사항으로 분절할 수 있다.The sentence segmentation unit 110 may segment the API document in units of sentences. The sentence segmentation unit 110 may segment into a single requirement in order to extract a specific relationship.

코드분절부(120)는 테스트코드를 단일의미구간으로 분절할 수 있다. 코드분절부는(120)는 기대동작을 확인하는 구문을 기준으로 분절할 수 있다.The code segmentation unit 120 may segment the test code into single semantic sections. The code segmentation unit 120 may segment based on the syntax for confirming the expected operation.

연관관계추출부(130)는 문장분절부에서 분절된 문장과 상기 코드분절부에서 분절된 코드구간간의 연관관계를 추출할 수 있다. 연관관계추출부(130)는 메소드단위 매칭모듈(131), 매칭모듈(133), 유사도계산모듈(135), 추출모듈(137)로 구성된다. 메소드단위 매칭모듈(131)은 테스트 대상 메소드와 테스트 메소드를 메소드 단위로 매칭할 수 있다. 유사도계산모듈(135)은 메소드 단위로 매칭된 테스트 대상 메소드의 문장과 테스트 메소드의 코드구간 사이의 유사도를 계산할 수 있다.The association relation extraction unit 130 may extract a relation between a sentence segmented in the sentence segmentation unit and a code section segmented in the code segmentation unit. The relation extraction unit 130 is composed of a method unit matching module 131, a matching module 133, a similarity calculation module 135, and an extraction module 137. The method unit matching module 131 may match a test target method and a test method in a method unit. The similarity calculation module 135 may calculate the similarity between the sentence of the method to be tested matched on a method basis and the code section of the test method.

제공부(140)는 추출된 연관관계를 사용자단말에 제공할 수 있다. 사용자단말은 제공부로부터 제공된 연관관계를 통해 API문서의 주석에 링크를 삽입하여 API문서를 보강할 수 있고, 누락된 요구사항을 확인하여 누락된 주석을 보완할 수 있고,코드리뷰를 보조할 수 있다.The providing unit 140 may provide the extracted relation to the user terminal. The user terminal can reinforce the API document by inserting a link in the annotation of the API document through the association provided by the provisioning unit, can supplement the missing annotation by checking the missing requirements, and can assist in code review. there is.

도 4는 본 발명의 실시예에 따른 메소드단위 매칭모듈의 매칭 방법을 설명하는 예시도이다.4 is an exemplary view illustrating a matching method of a method unit matching module according to an embodiment of the present invention.

도 4를 참조하면, 메소드단위 매칭모듈이 메소드 호출을 고려한 메소드 단위 매칭 방법을 설명한다. 메소드 단위 연관관계를 탐지하는 기존 기법을 활용하며, 프로그램 메소드 m과 테스트 메소드 t가 있을 때, 다음 조건 중 하나를 만족하면 메소드 단위 매칭을 한다.Referring to FIG. 4 , a method unit matching method in which the method unit matching module considers method calls will be described. Existing techniques for detecting method unit correlation are utilized. When there is a program method m and a test method t, if one of the following conditions is satisfied, method unit matching is performed.

A : t에서 m을 호출하고 m이름이 t의 “test”를 제거한 이름과 정확히 일치A: Call m from t, and m's name exactly matches the name of t with "test" removed

B : t에서 m을 호출하고 t의 “test”를 제거한 이름과 정확히 일치하는 m′이 존재하지 않고 m이름이 t의 “test”를 제거한 이름의 부분 문자열(substring)을 만족B: Call m from t, and there is no m′ that exactly matches the name of t with “test” removed, and name m satisfies a substring of the name of t with “test” removed.

C : t에서 m을 호출하고 t의 “test”를 제거한 이름과 일치하거나 부분 문자열인 m′이 존재하지 않을 때C: Call m in t and match the name with “test” removed from t or the substring m′ does not exist

도 5는 본 발명의 실시예에 따른 유사도계산 모듈의 유사도 계산 방법을 설명하는 예시도이다.5 is an exemplary view illustrating a similarity calculation method of a similarity calculation module according to an embodiment of the present invention.

도 5를 참조하면, 유사도계산 모듈의 유사도 계산 방법으로 전처리 과정과 벡터화 과정을 거친다. 벡터화 과정은 문장과 코드 구간의 단어들을 전체 단어 집합으로 생성하고, 문장은 문장끼리, 코드는 코드끼리 TF-IDF 등의 벡터화 알고리즘을 활용할 수 있다.Referring to FIG. 5, as a similarity calculation method of the similarity calculation module, a preprocessing process and a vectorization process are performed. In the vectorization process, words in sentences and code sections are generated as whole word sets, and a vectorization algorithm such as TF-IDF can be used to divide sentences into sentences and codes into codes.

TF-IDF 알고리즘을 활용하는 경우, 백터화의 전처리 과정은 공백을 기준으로 단어를 분리하고, 불용어(stopword), HTML tag, 특수문자를 제거한다. Camel case로 작성된 단어를 유지하고 Camel case로 분리된 단어 추가하고, 각 단어를 소문자로 변환한다.When using the TF-IDF algorithm, the vectorization preprocessing process separates words based on spaces and removes stopwords, HTML tags, and special characters. Keeps the words written in camel case, adds words separated by camel case, and converts each word to lower case.

문장에서 등장하는 단어 빈도수와 코드에서 등장하는 단어 빈도수의 중요도가 다르며, 구문의 길이에 따라 단어의 상대적 빈도를 조정하기 위한 정규화(normalization)를 수행한다.The importance of the frequency of words appearing in the sentence and the frequency of words appearing in the code are different, and normalization is performed to adjust the relative frequency of words according to the length of the phrase.

도 6은 본 발명의 실시예에 따른 매칭모듈이 매칭하는 방법을 설명하는 예시도이다. 도 6을 참조하면, 매칭모듈은 연관성 링크를 생성하는 규칙으로, JavaDoc 문장마다 가장 유사한 테스트 코드 구간과 링크를 생성하고, 테스트 코드 구간마다 가장 유사한 JavaDoc 문장과 링크를 생성한다. 단, 어떠한 대상과도 유사도가 일관되게 낮은 문장/테스트코드구간은 제외한다. 예컨대, 전체평균 유사도 이상의 유사도를 갖는 대상이 없고, 모든 대상과의 유사도 분산(deviation)이 전체 유사도 분산보다 낮은 경우를 말한다.6 is an exemplary view illustrating a matching method by a matching module according to an embodiment of the present invention. Referring to FIG. 6 , the matching module generates the most similar test code section and link for each JavaDoc sentence, and generates the most similar JavaDoc sentence and link for each test code section. However, sentences/test code sections with consistently low similarity with any subject are excluded. For example, it refers to a case in which there is no object having a similarity higher than the overall average similarity, and the similarity deviation with all objects is lower than the total similarity variance.

도 7 내지 도 10은 본 발명의 실시예에 따른 실험 결과를 나타내는 테이블이다. 도 7 내지 도 10을 참조하면, 본 발명의 방법을 JavaDoc과 JUnit 코드에 대해 동작하는 도구로 구현하고, 오픈소스 Java 프로젝트에서 실제 존재하는 JavaDoc 문장과 JUnit 코드 구간의 연관관계를 조사한 데이터셋을 구성하여 평가에 사용하였다. JavaDoc 주석과 JUnit 코드의 양이 평균 이상인 30개 클래스를 대상으로 7 to 10 are tables showing experimental results according to an embodiment of the present invention. Referring to FIGS. 7 to 10, the method of the present invention is implemented as a tool that operates on JavaDoc and JUnit code, and a dataset is constructed by examining the relationship between JavaDoc sentences and JUnit code sections that actually exist in an open source Java project. and used for evaluation. 30 classes with an above-average amount of JavaDoc comments and JUnit code.

총 800쌍의 JavaDoc 문장과 JUnit 코드라인을 정답으로 판별한다. A total of 800 pairs of JavaDoc sentences and JUnit code lines are determined as correct answers.

본 발명의 방법으로 문장-테스트코드 구간 단위 연관관계를 얼마나 정확하게 추출하는 지 여부와 실제로 연관관계가 전혀 존재하지 않는 문장과 테스트코드 구간을 얼마나 정확하게 탐지하는 지 여부를 실험하였다.We tested how accurately the sentence-test code section-by-unit correlation was extracted by the method of the present invention and how accurately it detected sentences and test code sections that did not actually have any correlation at all.

비교대상기법은 Method-All 방법과 Method-One 방법으로, Method-All은 메소드 수준 매칭 관계를 소려할 때 발생 가능한 문자-코드구간 쌍에 대해 링크를 생성하고, Method-One은 메소드 수준 매칭 관계를 고려할 때 발생 가능한 임의의 한 쌍의 문장-코드구간에 대해 링크를 생성한다.The comparison target techniques are the Method-All method and the Method-One method. Method-All creates a link for the text-code section pair that can occur when refining the method-level matching relationship, and Method-One creates a link for the method-level matching relationship. Links are created for any pair of sentence-code sections that can occur when considered.

도 8을 참조하면, 실재하는 문장-테스트코드구간 연관관계를 정확하게 추출하는지에 대해서, 본 발명의 방법은 다른 기법보다 높은 precision을 보이고(최대 14.32%), Precision이 높은 SuperCSV와 같은 경우, 문장에 Exception 이름, 상수 값 등에 대한 언급이 많았고, Precision이 낮은 Collections의 경우, 복합적인 논리 조건 등 구문적 특징으로 유사도를 판별하기 어려운 문장이 많았다.Referring to FIG. 8, the method of the present invention shows higher precision than other techniques (up to 14.32%), and in the case of SuperCSV, which has a high precision, with respect to accurately extracting the relationship between the actual sentence and the test code section, the sentence There were many mentions of exception names and constant values, and in the case of collections with low precision, there were many sentences in which it was difficult to determine similarity due to syntactical characteristics such as complex logical conditions.

도 9를 참조하면, 연관관계가 전혀 존재하지 않는 문장을 정확하게 탐지하는 지에 대해서, 본 발명의 방법의 정밀도가 Precision 91.10%로 가장 높으며, 8.9%의 오탐지는 동일한 내용의 테스트코드 구간이 부재인 경우이거나 제안하는 기법의 한계인 경우이다. Referring to FIG. 9, the precision of the method of the present invention is the highest at 91.10% for accurately detecting sentences that do not have any correlation, and 8.9% of false positives are the absence of a test code section with the same content. This is either a case or a limitation of the proposed technique.

도 10을 참조하면, 연관관계가 존재하지 않는 테스트코드 구간을 정확히 탐지하는 지에 대해서, 본 발명의 방법의 정밀도가 Precision 88.12%로 제안한 기법의 정밀도가 가장 높으며, 11.88%의 오탐지는 동일한 내용의 문장이 부재인 경우이다.Referring to FIG. 10, regarding whether to accurately detect a test code section in which there is no correlation, the precision of the method proposed by the present invention is 88.12%, which is the highest precision, and 11.88% of false positives have the same content. In case the sentence is absent.

도 11 내지 도 13은 본 발명의 실시예에 따른 추출한 연관관계를 활용하는 예시도이다. 도 11을 참조하면, 연관관계가 추출된 JavaDoc 문장과 테스트 코드 구간이 실제로 동일한 의미의 요구사항을 표현하고 있는 지를 검사할 수 있다. 도 11은 실험 결과를 바탕으로 실제 발견한 잘못된 요구사항 표현 사례를 나타내고 있다. @throws 문장에 작성된 JavaDoc 문장과 테스트 코드에 작성된 내용의 불일치로 인해 JavaDoc 문장과 테스트 코드에 추가적인 작성이 필요하며, 인식되지 않은 key 와 입력 값 null에 따른 서로 다른 동작으로 인해 사용자에게 혼란을 줄 수 있다. 도 12를 참조하면, 어떠한 연관관계도 추출되지 않은 JavaDoc 문장에 대하여 해당 요구사항이 테스트코드에 표현되지 않고 누락한 것인지 검토할 수 있다.11 to 13 are exemplary diagrams of utilizing extracted correlations according to an embodiment of the present invention. Referring to FIG. 11 , it is possible to check whether the JavaDoc sentence and the test code section from which the correlation is extracted actually express the requirements of the same meaning. 11 shows examples of incorrect expression of requirements actually discovered based on the experimental results. Due to the inconsistency between the JavaDoc sentence written in the @throws sentence and the content written in the test code, additional writing is required in the JavaDoc sentence and the test code, and different actions depending on the unrecognized key and input value null may cause confusion to the user. there is. Referring to FIG. 12, it is possible to examine whether the corresponding requirements are not expressed in the test code and are omitted for the JavaDoc sentences from which no relationship has been extracted.

도 13을 참조하면, 어떠한 연관관계가 추출되지 않은 JUnit 테스트 코드 구간에 대해서 해당 요구사항이 JavaDoc에 표현되지 않았는지 검토할 수 있다.Referring to FIG. 13, it can be reviewed whether the corresponding requirements are not expressed in the JavaDoc for the JUnit test code section from which no relation has been extracted.

본 발명은 도면에 도시된 실시 예를 참고로 설명되었으나 이는 예시적인 것에 불과하며, 본 기술 분야의 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 타 실시 예가 가능하다는 점을 이해할 것이다. 따라서, 본 발명의 진정한 기술적 보호 범위는 첨부된 등록청구범위의 기술적 사상에 의해 정해져야 할 것이다.Although the present invention has been described with reference to the embodiments shown in the drawings, this is only exemplary, and those skilled in the art will understand that various modifications and equivalent other embodiments are possible therefrom. Therefore, the true technical protection scope of the present invention should be determined by the technical spirit of the attached claims.

10; API 문서와 테스트 코드간 연관성 추출 시스템 100; 연관성추출서버
110; 문장분절부 120; 코드분절부
130; 연관관계추출부 131; 메소드단위 매칭모듈
133; 매칭모듈 135; 유사도계산모듈
137; 추출모듈 140; 제공부
150; 통신부 160; 제어부
200; 사용자단말
10; Association extraction system 100 between API documents and test codes; Association extraction server
110; Sentence segmentation unit 120; code segment
130; Relationship extraction unit 131; Method Unit Matching Module
133; Matching module 135; Similarity calculation module
137; Extraction module 140; provision department
150; communication unit 160; control unit
200; user terminal

Claims (5)

API 문서와 테스트 코드간의 연관성을 추출하는 방법에 관한 것으로,
(a) 문장분절부가 API문서를 문장 단위로 분절하는 단계;
(b) 코드분절부가 테스트코드를 단일의미구간으로 분절하는 단계; 및
(c) 연관관계추출부가 문장분절부에서 분절된 문장과 코드분절부에서 분절된 코드구간간의 연관관계를 추출하는 단계를 포함하는 API 문서와 테스트 코드간의 연관성 추출방법.
It is about a method of extracting the association between API documents and test codes,
(a) Segmenting the API document by sentence by sentence segmentation unit;
(b) segmenting the test code into single semantic sections by the code segmentation unit; and
(c) A method of extracting a correlation between an API document and a test code, including a step of extracting a relation between a sentence segmented in the sentence segment unit and a code section segmented in the code segment unit by the association relation extraction unit.
제1항에 있어서,
상기 (c) 단계는,
상기 연관관계추출부는 메소드단위매칭모듈, 유사도계산모듈, 매칭모듈, 추출모듈로 구성되고,
(c-1) 상기 메소드단위매칭모듈이 테스트 대상 메소드와 테스트 메소드를 메소드 단위로 매칭하는 단계;
(c-2) 상기 유사도계산모듈이 메소드 단위로 매칭된 테스트 대상 메소드의 문장과 테스트 메소드의 코드구간 사이의 유사도를 계산하는 단계를 포함하는 API 문서와 테스트 코드간의 연관성 추출방법.
According to claim 1,
In step (c),
The association relation extraction unit is composed of a method unit matching module, a similarity calculation module, a matching module, and an extraction module,
(c-1) matching, by the method unit matching module, the method to be tested and the test method in unit of method;
(c-2) A method of extracting a correlation between an API document and a test code, comprising calculating, by the similarity calculation module, a degree of similarity between a sentence of a method to be tested matched on a method basis and a code section of the test method.
제2항에 있어서,
(c-3) 상기 매칭모듈이 계산된 유사도를 이용하여 문장과 코드구간을 매칭하는 단계를 더 포함하는 API 문서와 테스트 코드간의 연관성 추출방법.
According to claim 2,
(c-3) A method of extracting correlation between an API document and a test code, further comprising matching a sentence and a code section using the similarity calculated by the matching module.
제3항에 있어서,
(c-4) 상기 추출모듈이 연관관계를 갖는 문장과 코드구간 쌍을 추출하는 단계를 더 포함하는 API 문서와 테스트 코드간의 연관성 추출방법.
According to claim 3,
(c-4) A method of extracting a correlation between an API document and a test code, further comprising the step of extracting, by the extraction module, a pair of sentences and code sections having a correlation.
연관성추출서버와 사용자단말로 구성된 API 문서와 테스트 코드간의 연관성을 추출하는 시스템에 있어서,
API문서를 문장 단위로 분절하는 문장분절부;
테스트코드를 단일의미구간으로 분절하는 코드분절부; 및
상기 문장분절부에서 분절된 문장과 상기 코드분절부에서 분절된 코드구간간의 연관관계를 추출하는 연관관계추출부를 포함하고,
상기 연관관계추출부는 테스트 대상 메소드와 테스트 메소드를 메소드 단위로 매칭하는 메소드단위매칭모듈과, 메소드 단위로 매칭된 테스트 대상 메소드의 문장과 테스트 메소드의 코드구간 사이의 유사도를 계산하는 유사도계산모듈을 포함하는 API 문서와 테스트 코드간의 연관성 추출 시스템.



















In the system for extracting the correlation between the API document and the test code composed of a correlation extraction server and a user terminal,
A sentence segmentation unit that segments the API document into sentence units;
a code segmentation unit for segmenting the test code into single semantic sections; and
A relationship extraction unit for extracting a relationship between a sentence segmented in the sentence segmentation unit and a code section segmented in the code segmentation unit;
The correlation extraction unit includes a method unit matching module that matches the test method and the test method on a method-by-method basis, and a similarity calculation module that calculates the similarity between the sentence of the test target method matched on a method-by-method basis and the code section of the test method. A system for extracting associations between API documents and test codes.



















KR1020210097630A 2021-07-26 2021-07-26 Method and system for extracting fine-grained traceability links between API document comments and test code lines KR102567407B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020210097630A KR102567407B1 (en) 2021-07-26 2021-07-26 Method and system for extracting fine-grained traceability links between API document comments and test code lines

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020210097630A KR102567407B1 (en) 2021-07-26 2021-07-26 Method and system for extracting fine-grained traceability links between API document comments and test code lines

Publications (2)

Publication Number Publication Date
KR20230016322A true KR20230016322A (en) 2023-02-02
KR102567407B1 KR102567407B1 (en) 2023-08-14

Family

ID=85225461

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020210097630A KR102567407B1 (en) 2021-07-26 2021-07-26 Method and system for extracting fine-grained traceability links between API document comments and test code lines

Country Status (1)

Country Link
KR (1) KR102567407B1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909533A (en) * 2023-09-13 2023-10-20 北京安锐卓越信息技术股份有限公司 Method and device for editing computer program statement, storage medium and electronic equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009237654A (en) * 2008-03-26 2009-10-15 Hitachi Software Eng Co Ltd Test program management system
KR20120053707A (en) * 2010-11-18 2012-05-29 주식회사 차후 2 dimension code searching and storing device
JP2014049066A (en) * 2012-09-04 2014-03-17 Fujitsu Ltd Program, information processor, and testing method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009237654A (en) * 2008-03-26 2009-10-15 Hitachi Software Eng Co Ltd Test program management system
KR20120053707A (en) * 2010-11-18 2012-05-29 주식회사 차후 2 dimension code searching and storing device
JP2014049066A (en) * 2012-09-04 2014-03-17 Fujitsu Ltd Program, information processor, and testing method

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116909533A (en) * 2023-09-13 2023-10-20 北京安锐卓越信息技术股份有限公司 Method and device for editing computer program statement, storage medium and electronic equipment
CN116909533B (en) * 2023-09-13 2024-01-26 北京安锐卓越信息技术股份有限公司 Method and device for editing computer program statement, storage medium and electronic equipment

Also Published As

Publication number Publication date
KR102567407B1 (en) 2023-08-14

Similar Documents

Publication Publication Date Title
Clement et al. PyMT5: multi-mode translation of natural language and Python code with transformers
Al Omran et al. Choosing an NLP library for analyzing software documentation: a systematic literature review and a series of experiments
Jiang et al. An unsupervised approach for discovering relevant tutorial fragments for APIs
Sureka et al. Detecting duplicate bug report using character n-gram-based features
US8539475B2 (en) API backward compatibility checking
CA3088692C (en) Visualizing comment sentiment
Xu et al. Open information extraction with tree kernels
Motwani et al. Automatically generating precise oracles from structured natural language specifications
US11775414B2 (en) Automated bug fixing using deep learning
CN112699665B (en) Triple extraction method and device of safety report text and electronic equipment
Nguyen et al. Filtering noise in mixed-purpose fixing commits to improve defect prediction and localization
Tran et al. Does BLEU score work for code migration?
Liu et al. Identifying renaming opportunities by expanding conducted rename refactorings
Zhong et al. Inferring specifications for resources from natural language API documentation
CN111507086A (en) Automatic discovery of translation text location in localized applications
CN109830272B (en) Data standardization method and device, computer equipment and storage medium
Fischbach et al. Towards causality extraction from requirements
CN115080406A (en) Code log generation method, device, equipment and storage medium
KR102567407B1 (en) Method and system for extracting fine-grained traceability links between API document comments and test code lines
Wang et al. {NLP-EYE}: Detecting Memory Corruptions via {Semantic-Aware} Memory Operation Function Identification
Kamune et al. Hybrid approach to pronominal anaphora resolution in English newspaper text
Pawelka et al. Is this code written in English? A study of the natural language of comments and identifiers in practice
Kamezawa et al. Rnsum: A large-scale dataset for automatic release note generation via commit logs summarization
CN110989991B (en) Method and system for detecting source code clone open source software in application program
Kumar et al. OntoCat: Automatically categorizing knowledge in API Documentation

Legal Events

Date Code Title Description
E90F Notification of reason for final refusal
E701 Decision to grant or registration of patent right
GRNT Written decision to grant