WO2024053772A1 - 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체 - Google Patents

단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체 Download PDF

Info

Publication number
WO2024053772A1
WO2024053772A1 PCT/KR2022/014113 KR2022014113W WO2024053772A1 WO 2024053772 A1 WO2024053772 A1 WO 2024053772A1 KR 2022014113 W KR2022014113 W KR 2022014113W WO 2024053772 A1 WO2024053772 A1 WO 2024053772A1
Authority
WO
WIPO (PCT)
Prior art keywords
function
test
unit test
changed
changing
Prior art date
Application number
PCT/KR2022/014113
Other languages
English (en)
French (fr)
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 슈어소프트테크주식회사
Publication of WO2024053772A1 publication Critical patent/WO2024053772A1/ko

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software

Definitions

  • the present invention relates to a unit test reuse method and a computer-readable recording medium that can reuse unit tests affected by source code changes by linking them with newly analyzed source code information.
  • Unit tests depend on the form of the source code. If the form of functions changes due to changes in source code, unit tests created for existing functions may become unusable. For example, when there is a function that takes two integer values as parameters, the unit test for it is also designed to take two input values. However, if the function's parameters increase to three integer values due to changes in the source code, the existing test becomes unusable. This is because the existing unit test is designed to accept only two input values, so the connection with the newly changed function is lost. Users who were trying to do regression testing due to source changes must design and create new unit tests because the unit tests have become unusable, which takes a lot of time. This results in a negative impact on overall test maintenance.
  • the present invention was created in consideration of the above-mentioned problems, and the purpose of the present invention is to confirm changes in source code in a unit test tool, identify test assets to apply the changes, and furthermore, provide a unit that can maintain the existing test environment. It provides a test reuse method and a computer-readable recording medium.
  • a unit test reuse method for achieving the above object includes the steps of identifying the unit test as a reset target based on whether the test target function and global variable of the pre-generated unit test are changed; Changing a test target function of the unit test that has been reset; changing global variable information of the unit test that is the reset target; changing stub information of the unit test that has been reset based on the changed test target function; and changing fault injection information of the unit test that has been reset based on the changed function under test.
  • the identifying step includes measuring the similarity between the test target function of the current source code and the test target function of the parasitic generated unit test; and when the similarity is greater than or equal to a predetermined value, determining the unit test as a reset target.
  • the similarity may be measured based on the edit distance of the function name excluding parameters, the file name of the source code containing the function, and the file path of the source code containing the function.
  • the step of measuring the similarity measures the similarity by assigning different weights to the edit distance of the function name excluding the parameter, the file name of the source code containing the function, and the file path of the source code containing the function. can do.
  • the edit distance of the function name excluding the parameters, the file name of the source code containing the function, and the file path of the source code containing the function are weighted at a ratio of 10:5:1.
  • the similarity can be measured by giving .
  • the step of changing the test target function may create a new unit test from a new function connected to the reset target unit test.
  • At least one of the name, parameters, and return value of the function under test of the new unit test may be modified to correspond to the unit test that has become the reset target.
  • the step of changing the stub information includes determining whether at least one of the name, parameters, and return value of the stub function is changed; and when at least one of the name, parameters, and return value of the stub function is changed, converting the stub information to correspond to the changed test target function.
  • changing the fault injection information may include checking a change range of the changed test target function; and changing the defect injection information based on the change range.
  • a computer-readable recording medium for achieving the above purpose may record a program for performing the above unit test reuse method.
  • unit test reuse method and computer-readable recording medium it is possible to determine which test a change in source code will affect and modify it, thereby making it possible to reuse previously created unit tests.
  • FIG. 1 is a functional flow diagram of a unit test reuse method according to the present invention.
  • Figure 2 illustrates the steps for performing test asset identification that requires resetting.
  • Figure 3 shows steps for performing function conversion by measuring the similarity of the change function and examining reconfigurable function candidates.
  • Figure 4 shows the steps in which the test is reset according to the changed function.
  • Figure 5 is a table listing the structure of the existing source code and the structure of the changed source code.
  • Figure 6 shows steps for performing global variable conversion.
  • Figure 7 shows steps for performing stub information change.
  • the unit test reuse method according to the present invention includes a global variable information change step, a function information change step, a stub information change step, and a fault injection information change step.
  • the unit test reuse method according to the present invention first identifies the unit test as a reset target based on whether the test target function and global variable of the parasitically generated unit test are changed. Thereafter, steps are taken to change the test target function of the unit test that has been reset, and to change global variable information of the unit test that has been reset. Thereafter, the stub information of the unit test subject to reset is changed based on the changed test subject function, and the fault injection information of the unit test subject to reset is changed based on the changed test subject function, thereby performing the unit test. It can be reused.
  • Figure 2 illustrates the steps for performing test asset identification that requires resetting.
  • a mismatch checker checks for inconsistencies between the existing function information and the existing global variable information. The mismatch checker passes mismatches to the associated test asset explorer. If the information associated with a previously created unit test does not match, the unit test and related assets are identified as targets for reset.
  • Unit testing is intended to verify whether a unit within software operates as intended, and in the present invention, this unit is defined as a function. These functions are called test target functions of unit tests. Unit test designs can include global variables that can affect test results depending on their purpose.
  • a global variable refers to a variable declared so that it can be accessed from all areas of the source code.
  • Unit tests are subject to reset when the function under test is changed or a global variable is changed. Changes to functions are judged based on changes to the function's name, parameters, and return value. At this time, the function can be automatically reset by measuring the similarity of the function. Global variables are based on when the names of global variables used in unit test code are changed.
  • the step of identifying a unit test as a reset target due to a function change includes measuring the similarity between the test target function of the current source code and the test target function of the pre-generated unit test, and if the similarity is greater than a predetermined value, It may include determining a unit test to be reset.
  • the similarity may be measured based on the edit distance of the function name excluding parameters, the file name of the source code containing the function, and the file path of the source code containing the function.
  • the step of measuring the similarity measures the similarity by assigning different weights to the edit distance of the function name excluding the parameter, the file name of the source code containing the function, and the file path of the source code containing the function. You can. At this time, the similarity is measured by weighting the edit distance of the function name excluding the parameter, the file name of the source code containing the function, and the file path of the source code containing the function at a ratio of 10:5:1. You can.
  • Figure 3 shows steps for performing function conversion by measuring the similarity of the change function and examining reconfigurable function candidates.
  • the similarity meter measures the similarity between newly analyzed functions and existing functions after changing the source code. Similarity can be expressed in the form of edit distance, and can be automatically reset if the edit distance has a high similarity close to 0.
  • the edit distance is a way to quantify how different two strings are from each other, and represents the minimum number of modifications for two strings to become the same.
  • the standards for measuring similarity are as follows, and are listed in descending order of weight contributing to similarity. However, it is also possible to change the order of weights depending on the embodiment.
  • Each weight ratio may be 10:5:1. If the name is the same but the file path is different, the weight for the file path may be set to the lowest because the file may have the same content but has only been moved. When functions have different names, the weight can be set to the highest because the lower the similarity between the names, the lower the probability that they are the same function. The higher the weight, the lower the edit distance is calculated. If the edit distance exceeds 35, it can be left as a resettable candidate so that the user can make his own judgment. This is a number that is judged to require confirmation by the user when measuring the edit distance by weighting it in the ratio above. This is a result obtained empirically from actual code change cases by users performing unit tests. Functions with the most similar names have a higher similarity and are therefore more likely to be selected for change.
  • the step of changing the test target function may include creating a new unit test from a new function connected to the reset target unit test. At this time, at least one of the name, parameters, and return value of the test target function of the new unit test can be modified to correspond to the unit test that has become the reset target.
  • Figure 4 shows the steps in which the test is reset according to the changed function.
  • the parameters of the test target function set in the existing test are two constant values, they can be modified to receive the same values in the new unit test. If the number of parameters of the newly connected function is greater than that of the existing function, the unit test is modified to receive new input values as many as the newly added variables.
  • Changing the global variable may include determining whether the name of the global variable of the function under test has changed, and, if the name of the global variable has been changed, collectively changing the changed global variable for a new unit test. .
  • Figure 5 is a table listing the structure of the existing source code and the structure of the changed source code. The structure in the existing source code is described on the left side of Figure 5, and the structure in the changed source code is described on the right side of Figure 5. .
  • Figure 6 shows steps for performing global variable conversion.
  • the unit test can be modified and reused by mapping the names of the existing variable and the changed variable. If the name of a global variable named var is changed to var_modified, the change can be entered by the user in a dedicated window. Based on the changes entered, the global variable converter can apply the changes in batches to all unit tests that use the varglobal variable.
  • the global variable is a structure type
  • the global variable subject to change may increase by the number of fields used in the test.
  • variable batch change function you can batch apply changes to fields within the same structure with a single change.
  • Variables are managed in the form of an array based on the dot operator (.), and when the name at the beginning of the array is changed (SampleStructure is changed to SampleStructure_modified in the table in Figure 5), other global variables with the same name at the same index are also global to the same structure. Judging by the variable, the same changes are applied. If you find global variables belonging to the same structure and change their names, you can apply all other changes with one change.
  • the global variable name analyzer extracts inconsistent global variable information.
  • the global variable list checker checks whether there is an identical global variable, and the global variable converter applies batch changes if there is an identical global variable.
  • the step of changing the stub information includes determining whether at least one of the name, parameters, and return value of the stub function has changed, and if at least one of the name, parameters, and return value of the stub function has changed, the changed test target
  • a step of converting stub information to correspond to a function may be included.
  • Figure 7 shows steps for performing stub information change.
  • the change target stub identifier that receives existing stub information and changed function information transmits a list of stubs that need to be changed to the stub converter. Based on the change stub information and existing test information transmitted from the stub converter, the stub connection information resetter stores the changed stub information.
  • Changing the fault injection information may include checking a change range of the changed function under test, and changing the fault injection information based on the change range.
  • Unit tests designed for fault injection testing include fault injection code. Since the fault injection code is information related to the function body, if the body is changed, it may behave differently from the intention of the tester. Therefore, line information and code information for each line, that is, the function body, are stored and managed. At this time, if the function information is changed, the scope of change is checked and the fault injection code is reset.
  • the change range identifier identifies the required change range of fault injection information (code) based on existing fault injection information and changed function information. Once the scope for change is identified, the automatic fault injection information location converter transmits the converted fault injection information to the fault injection information checker, and the fault injection information checker stores the changed fault injection information.
  • the unit test reset method described above can be implemented in the form of program instructions that can be executed through various computer means and recorded on a computer-readable recording medium.
  • a computer-readable recording medium may include program instructions, data files, data structures, etc., singly or in combination. Program instructions recorded on the medium may be specially designed and constructed for the present invention or may be known and usable by those skilled in the art of computer software. Examples of computer-readable recording media include magnetic media such as hard disks, floppy disks, and magnetic tapes, optical media such as CD-ROMs and DVDs, and magnetic media such as floptical disks. -Includes optical media (magneto-optical media) and hardware devices specifically configured to store and execute program instructions, such as ROM, RAM, flash memory, etc.
  • program instructions include machine language code, such as that produced by a compiler, as well as high-level language code that can be executed by a computer using an interpreter, etc.
  • the hardware devices described above may be configured to operate as one or more software modules to perform the operations of the present invention, and vice versa.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

본 발명에 따른 단위 테스트 재사용 방법은, 기생성된 단위 테스트의 테스트 대상 함수 및 전역 변수의 변경 여부에 기초하여 상기 단위 테스트를 재설정 대상으로 식별하는 단계, 재설정 대상이 된 상기 단위 테스트의 테스트 대상 함수를 변경하는 단계, 상기 재설정 대상이 된 상기 단위 테스트의 전역 변수 정보를 변경하는 단계, 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 스텁 정보를 변경하는 단계, 및 상기 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 결함 주입 정보를 변경하는 단계를 포함한다.

Description

단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체
본 발명은 소스 코드 변경으로 인해 영향을 받는 단위 테스트를 새로 분석된 소스 코드 정보와 연결하여 재사용할 수 있는 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체에 관한 것이다.
단위 테스트는 소스 코드의 형태에 의존한다. 만일 소스 코드의 변경으로 인해 함수들의 형태가 바뀌게 된다면, 기존 함수에 맞게 생성된 단위 테스트를 사용하지 못하게 될 수 있다. 예를 들어, 정수값 두 개를 파라미터로 받는 함수가 있을 때 이에 대한 단위 테스트 역시 입력값 두 개를 받도록 설계된다. 하지만, 소스 코드의 변경으로 함수의 파라미터가 정수값 세 개로 늘어나는 경우에는 기존 테스트를 사용할 수 없게 된다. 기존 단위 테스트는 입력값을 두 개만 받도록 설계되어 있어 새로 변경된 함수와의 연결이 끊어지기 때문이다. 소스 변경으로 인해 회귀 테스트를 하려던 사용자는 사용할 수 없게 된 단위 테스트 때문에 새로운 단위 테스트를 설계하고 생성해야 하며 많은 시간이 소요된다. 이는 전체 테스트 유지관리에 악영향을 미치는 결과를 초래한다.
[선행기술문헌]
[특허문헌]
대한민국 공개특허공보 제10-2021-0158015호 (2021년12월30일 공개)
본 발명은 상술한 문제점을 감안하여 안출된 것으로, 본 발명의 목적은 단위 테스트 도구에서 소스 코드의 변경을 확인하고 변경사항을 적용할 테스트 자산들을 식별하며, 더 나아가 기존 테스트 환경을 유지할 수 있는 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체를 제공함에 있다.
상기 목적을 달성하기 위한 본 발명에 따른 단위 테스트 재사용 방법은, 기생성된 단위 테스트의 테스트 대상 함수 및 전역 변수의 변경 여부에 기초하여 상기 단위 테스트를 재설정 대상으로 식별하는 단계; 재설정 대상이 된 상기 단위 테스트의 테스트 대상 함수를 변경하는 단계; 상기 재설정 대상이 된 상기 단위 테스트의 전역 변수 정보를 변경하는 단계; 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 스텁 정보를 변경하는 단계; 및 상기 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 결함 주입 정보를 변경하는 단계;를 포함한다.
상기 식별하는 단계는, 현재 소스 코드의 테스트 대상 함수와 상기 기생성된 단위 테스트의 테스트 대상 함수 사이의 유사도를 측정하는 단계; 및 상기 유사도가 소정값 이상인 경우, 상기 단위 테스트를 재설정 대상으로 결정하는 단계;를 포함할 수 있다.
그리고, 상기 유사도를 측정하는 단계는, 파라미터를 제외한 함수 이름, 함수가 있는 소스 코드의 파일 이름 및 함수가 있는 소스 코드의 파일 경로의 편집 거리에 기초하여 상기 유사도를 측정할 수 있다.
또한, 상기 유사도를 측정하는 단계는, 상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 서로 상이한 가중치를 부여하여 상기 유사도를 측정할 수 있다.
그리고, 상기 유사도를 측정하는 단계는, 상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 대하여 10:5:1의 비율로 가중치를 부여하여 상기 유사도를 측정할 수 있다.
또한, 상기 테스트 대상 함수를 변경하는 단계는, 상기 재설정 대상이 된 상기 단위 테스트와 연결된 신규 함수로부터 신규 단위 테스트를 생성할 수 있다.
그리고, 상기 테스트 대상 함수를 변경하는 단계는, 상기 신규 단위 테스트의 테스트 대상 함수의 이름, 매개변수 및 반환값 중 적어도 하나를 상기 재설정 대상이 된 상기 단위 테스트에 대응하여 수정할 수 있다.
또한, 상기 테스트 대상 함수의 전역 변수의 이름의 변경 여부를 판단하는 단계; 및 상기 전역 변수의 이름이 변경된 경우, 변경된 전역 변수를 신규 단위 테스트에 대하여 일괄 변경하는 단계;를 더 포함할 수 있다.
그리고, 상기 스텁 정보를 변경하는 단계는, 스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나의 변경 여부를 판단하는 단계; 및 스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나가 변경된 경우, 변경된 테스트 대상 함수에 대응하도록 스텁 정보를 변환하는 단계;를 포함할 수 있다.
또한, 상기 결함 주입 정보를 변경하는 단계는, 상기 변경된 테스트 대상 함수의 변경 범위를 확인하는 단계; 및 상기 변경 범위에 기초하여 상기 결함 주입 정보를 변경하는 단계;를 포함할 수 있다.
한편, 상기 목적을 달성하기 위한 컴퓨터 판독 가능 기록매체는 상기의 단위 테스트 재사용 방법을 수행하기 위한 프로그램을 기록할 수 있다.
본 발명에 따른 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체에 의하면, 소스 코드의 변경이 어떤 테스트에 영향을 미칠지 판단하고 이를 수정할 수 있게 됨으로써 기존에 생성된 단위 테스트를 재사용할 수 있게 된다.
도 1은 본 발명에 따른 단위 테스트 재사용 방법의 기능 흐름도이다.
도 2는 재설정이 필요한 테스트 자산 식별을 수행하는 단계를 도시한다.
도 3은 변경 함수의 유사도를 측정하고 재설정 가능한 함수 후보를 검사하여 함수 변환을 수행하는 단계를 도시한다.
도 4는 변경된 함수에 따라 테스트가 재설정되는 단계를 도시한다.
도 5는 기존 소스코드의 구조체와 변경된 소스코드의 구조체를 기재한 표이다.
도 6은 전역 변수 변환을 수행하는 단계를 도시한다.
도 7은 스텁 정보 변경을 수행하는 단계를 도시한다.
도 8은 결합 주입 정보 재설정을 수행하는 단계를 도시한다.
후술하는 본 발명에 대한 상세한 설명은, 본 발명이 실시될 수 있는 특정 실시 형태를 예시로서 도시하는 첨부 도면을 참조한다. 이들 실시 형태는 당업자가 본 발명을 실시할 수 있기에 충분하도록 상세히 설명된다. 본 발명의 다양한 실시 형태는 서로 다르지만 상호 배타적일 필요는 없음이 이해되어야 한다. 예를 들어, 여기에 기재되어 있는 특정 형상, 구조 및 특성은 일 실시 형태에 관련하여 본 발명의 정신 및 범위를 벗어나지 않으면서 다른 실시 형태로 구현될 수 있다. 또한, 각각의 개시된 실시 형태 내의 개별 구성요소의 위치 또는 배치는 본 발명의 정신 및 범위를 벗어나지 않으면서 변경될 수 있음이 이해되어야 한다. 따라서, 후술하는 상세한 설명은 한정적인 의미로서 취하려는 것이 아니며, 본 발명의 범위는, 적절하게 설명된다면, 그 청구항들이 주장하는 것과 균등한 모든 범위와 더불어 첨부된 청구항에 의해서만 한정된다. 도면에서 유사한 참조부호는 여러 측면에 걸쳐서 동일하거나 유사한 기능을 지칭한다.
이하에서는 첨부된 도면을 참조하면서 본 발명에 대하여 상세히 설명한다.
도 1은 본 발명에 따른 단위 테스트 재사용 방법의 기능 흐름도이다. 도 1을 참조하면, 본 발명에 따른 단위 테스트 재사용 방법은, 전역 변수 정보 변경 단계, 함수 정보 변경 단계, 스텁 정보 변경 단계 및 결함 주입 정보 변경 단계를 포함한다. 본 발명에 따른 단위 테스트 재사용 방법은, 먼저 기생성된 단위 테스트의 테스트 대상 함수 및 전역 변수의 변경 여부에 기초하여 상기 단위 테스트를 재설정 대상으로 식별한다. 이후, 재설정 대상이 된 상기 단위 테스트의 테스트 대상 함수를 변경하고, 상기 재설정 대상이 된 상기 단위 테스트의 전역 변수 정보를 변경하는 단계를 거친다. 이후, 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 스텁 정보를 변경하며, 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 결함 주입 정보를 변경함으로써, 단위 테스트를 재사용할 수 있게 된다.
1. 재설정이 필요한 테스트 자산 식별
도 2는 재설정이 필요한 테스트 자산 식별을 수행하는 단계를 도시한다.
도 2에 도시된 바와 같이, 변경된 소스 코드를 분석하고, 변경된 소스 코드 분석 정보의 함수 정보와 전역 변수 정보를 추출한 뒤, 불일치 검사기가 기존 함수 정보와 기존 전역 변수 정보와의 불일치 여부를 검사한다. 불일치 검사기는 불일치 항목을 연관된 테스트 자산 탐색기에 전달한다. 기존에 생성되어 있던 단위 테스트와 연관된 정보가 일치하지 않는 경우에는, 해당 단위 테스트 및 관련 자산들이 재설정 대상으로 식별된다.
2. 테스트 재설정
단위 테스트는 소프트웨어 내 하나의 단위가 의도한 대로 동작하는지를 검증하기 위한 것으로, 본 발명에서는 이 단위를 함수로 정의한다. 이러한 함수를 단위 테스트의 테스트 대상 함수라 칭한다. 단위 테스트 설계에는 목적에 따라 테스트 결과에 영향을 줄 수 있는 전역 변수를 포함할 수 있다. 전역 변수란 소스 코드의 모든 영역에서 접근할 수 있도록 선언된 변수를 의미한다.
단위 테스트는 테스트 대상 함수가 변경되거나 전역 변수가 변경되었을 때 재설정 대상이 된다. 함수의 변경은 함수의 이름, 매개변수, 반환값이 변경되었을 때를 기준으로 판단한다. 이때, 함수의 유사도 측정을 통해 자동으로 함수 재설정을 할 수 있다. 전역 변수는 단위 테스트 코드에 사용된 전역 변수의 이름이 변경되었을 때를 기준으로 한다.
2-1. 변경 함수의 유사도 측정
단위 테스트를 함수 변경에 따른 재설정 대상으로 식별하는 단계는, 현재 소스 코드의 테스트 대상 함수와 상기 기생성된 단위 테스트의 테스트 대상 함수 사이의 유사도를 측정하는 단계와, 상기 유사도가 소정값 이상인 경우 상기 단위 테스트를 재설정 대상으로 결정하는 단계를 포함할 수 있다.
이때, 유사도를 측정하는 단계는, 파라미터를 제외한 함수 이름, 함수가 있는 소스 코드의 파일 이름 및 함수가 있는 소스 코드의 파일 경로의 편집 거리에 기초하여 상기 유사도를 측정할 수 있다.
또한, 유사도를 측정하는 단계는, 상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 서로 상이한 가중치를 부여하여 상기 유사도를 측정할 수 있다. 이때, 상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 대하여 10:5:1의 비율로 가중치를 부여하여 상기 유사도를 측정할 수 있다.
도 3은 변경 함수의 유사도를 측정하고 재설정 가능한 함수 후보를 검사하여 함수 변환을 수행하는 단계를 도시한다.
유사도 측정기는 소스 코드 변경 후 새로 분석한 함수들과 기존 함수들의 유사도를 측정한다. 유사도는 편집 거리 형태로 나타낼 수 있고, 편집 거리가 0에 가까운 높은 유사도를 갖는 경우 자동으로 재설정할 수 있다. 여기서, 편집 거리란 두 문자열이 서로 얼마나 다른지에 대해 수량화하는 방법으로, 두 문자열의 같아지기 위한 최소 수정 횟수를 나타낸다. 유사도 측정 기준은 다음과 같으며 유사도에 기여하는 가중치가 높은 순서대로 나열하였다. 다만, 실시예에 따라서 가중치의 순서를 변경하는 것도 가능하다.
- 파라미터 제외한 함수 이름
- 함수가 있는 소스 코드의 파일 이름
- 함수가 있는 소스 코드의 파일 경로
각각의 가중치 비율은 10:5:1일 수 있다. 이름은 같으나 파일 경로가 다른 경우, 파일이 내용은 동일하되 이동만 했을 가능성이 있기 때문에 파일 경로에 대한 가중치가 가장 낮게 설정될 수 있다. 함수의 이름이 다른 경우에는 이름 간의 유사도가 떨어질수록 같은 함수일 가능성이 낮기 때문에 가중치가 가장 높게 설정될 수 있다. 가중치가 높을수록 낮은 편집 거리를 갖도록 계산되며 편집 거리가 35를 넘어가면, 사용자가 직접 판단할 수 있도록 재설정 가능 후보로 남길 수 있다. 이는 위와 같은 비율로 가중치를 두어 편집 거리를 측정했을 때, 사용자의 확인이 필요할 것이라고 판단되는 수치다. 이는 단위 테스트를 하는 사용자들의 실제 코드 변경 사례로부터 경험적으로 얻어낸 결과값이다. 가장 비슷한 이름을 가진 함수일수록 유사도가 높게 측정되어 변경 대상으로 선택 받을 가능성이 높다.
2-2. 테스트 대상 함수의 변경
테스트 대상 함수를 변경하는 단계는, 상기 재설정 대상이 된 상기 단위 테스트와 연결된 신규 함수로부터 신규 단위 테스트를 생성하는 단계를 포함할 수 있다. 이때, 상기 신규 단위 테스트의 테스트 대상 함수의 이름, 매개변수 및 반환값 중 적어도 하나를 상기 재설정 대상이 된 상기 단위 테스트에 대응하여 수정할 수 있다.
도 4는 변경된 함수에 따라 테스트가 재설정되는 단계를 도시한다. 재설정 대상이 된 단위 테스트와 새로운 함수를 연결하면, 새로운 함수로부터 새로운 단위 테스트를 생성하여 기존 테스트 설계를 복사하는 과정을 거친다.
만일, 기존 테스트에 설정된 테스트 대상 함수의 매개변수가 두 개의 상수값이라면 새로운 단위 테스트에서도 같은 값을 받을 수 있도록 수정될 수 있다. 만일 새로 연결된 함수의 매개변수의 개수가 기존 함수보다 많다면 새로 추가된 변수만큼 새로운 입력값을 받을 수 있는 형태로 단위 테스트가 수정된다.
2-3. 전역 변수 일괄 변경
전역 변수의 변경은, 상기 테스트 대상 함수의 전역 변수의 이름의 변경 여부를 판단하는 단계와, 상기 전역 변수의 이름이 변경된 경우 변경된 전역 변수를 신규 단위 테스트에 대하여 일괄 변경하는 단계를 포함할 수 있다.
도 5는 기존 소스코드의 구조체와 변경된 소스코드의 구조체를 기재한 표로, 도 5의 좌측에는 기존 소스코드에 있는 구조체가 기재되어 있고, 도 5의 우측에는 변경된 소스코드에 있는 구조체가 기재되어 있다. 도 6은 전역 변수 변환을 수행하는 단계를 도시한다.
전역 변수의 이름이 변경 된 경우, 기존 변수와 변경된 변수의 이름을 매핑하여 단위 테스트를 수정한 후 재사용할 수 있다. 이름이 var인 전역 변수의 이름이 var_modified라고 변경된 경우, 해당 변경 사항이 사용자에 의하여 전용 창에 입력될 수 있다. 입력된 변경 사항에 기초하여, 전역 변수 변환기는 var전역 변수를 사용한 모든 단위 테스트에 대해 변경 사항을 일괄적으로 적용할 수 있다.
전역 변수가 구조체 타입인 경우, 단위 테스트 설계에 구조체 전역 변수의 필드를 사용할 수 있다. 이 때 구조체의 이름이 변경된 경우 변경 대상이 되는 전역 변수가 테스트에 사용된 필드의 개수만큼 늘어날 수 있다.
도 5의 표를 참조하여 다시 설명하면, 변수 SampleStructure.a, SampleStructure.b, SampleStructure.c 를 사용하는 테스트가 있을 때 구조체의 이름이 변경되면 세 개의 변수가 모두 변경 대상이 된다.
전역 변수 일괄 변경 기능을 사용하면 동일한 구조체 내에 있는 필드는 한번의 변경으로 변경 사항을 일괄 적용할 수 있다. 도트연산자(.)를 기준으로 하여 변수를 배열 형태로 관리하고, 배열 앞부분의 이름이 변경(도 5의 표에서는 SampleStructure가 SampleStructure_modified으로 변경됨)되면 동일한 인덱스에 동일한 이름이 있는 다른 전역 변수 역시 동일한 구조체 전역 변수로 판단하여 같은 변경 사항을 적용한다. 이렇게 동일한 구조체에 속하는 전역 변수들을 찾아 이름을 변경하면 한번의 변경으로 다른 변경까지 일괄 적용할 수 있다.
도 6에 도시된 바와 같이, 기존 전역 변수 정보와 새로운 전역 변수 정보에 기초하여, 전역 변수 이름 분석기는 불일치하는 전역 변수 정보를 추출한다. 변경된 전역 변수가 입력되면, 전역 변수 목록 검사기는 동일한 전역 변수가 있는지를 검사하고, 전역 변수 변환기는 동일한 전역 변수가 있는 경우 일괄 변경을 적용한다.
3. 스텁의 재설정
스텁 정보를 변경하는 단계는, 스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나의 변경 여부를 판단하는 단계와, 스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나가 변경된 경우, 변경된 테스트 대상 함수에 대응하도록 스텁 정보를 변환하는 단계를 포함할 수 있다.
도 7은 스텁 정보 변경을 수행하는 단계를 도시한다.
테스트하고자 하는 함수 내에 테스트 대상 함수가 아닌 함수가 호출되는 경우, 사용자는 해당 함수를 가짜 함수로 대체할 수 있는데 이러한 함수를 스텁 또는 스텁 함수라고 한다. 스텁 함수를 사용하는 경우는 다음과 같다.
- 아직 구현되지 않은 함수
- 네트워크에 접근하는 등 테스트 환경에 의존적인 함수
- 레지스트리에 접근하는 등의 호출 위험이 큰 함수
- 실행 흐름을 제어할 필요가 있는 함수 등
단위 테스트의 테스트 대상 함수를 변경한 것처럼 스텁 함수를 변경할 수 있다. 스텁 함수의 이름, 매개변수, 반환값이 변경됐을 때 함수 재설정 대상이 되며, 테스트 대상 함수의 재사용 과정과 동일하게 새로운 함수로 스텁을 재설정하면 단위 테스트와의 기존 연결 정보가 유지되고 이에 따라 테스트 환경이 유지된다.
도 7에 도시된 바와 같이, 기존 스텁 정보와 변경된 함수 정보를 입력받은 변경 대상 스텁 식별기는, 변경이 필요한 스텁 목록을 스텁 변환기에 전달한다. 스텁 변환기에서 전달된 변경 스텁 정보 및 기존 테스트 정보에 기초하여, 스텁 연결 정보 재설정기는 변경된 스텁 정보를 저장한다.
4. 결함 주입 코드의 재설정
결함 주입 정보를 변경하는 단계는, 상기 변경된 테스트 대상 함수의 변경 범위를 확인하는 단계와, 상기 변경 범위에 기초하여 상기 결함 주입 정보를 변경하는 단계를 포함할 수 있다.
도 8은 결합 주입 정보 재설정을 수행하는 단계를 도시한다. 결함 주입 테스트를 위해 설계된 단위 테스트에는 결함 주입 코드가 포함된다. 결함 주입 코드는 함수 본문과 연관된 정보이기 때문에 본문이 변경되면 테스트하는 사용자의 의도와 다르게 동작할 수 있어 라인 정보와 각 라인의 코드 정보, 즉 함수 본문을 저장하여 관리한다. 이때 함수 정보가 변경되면 변경 범위를 확인하고 결함 주입 코드 재설정을 수행한다.
함수 본문 형상이 바뀌진 않았으나 함수의 라인이 변경된 경우는 함수가 선언된 위치만 변경되었을 가능성이 높다. 이 때는 결함 주입 코드의 라인 정보만 변경한다. 만일 소스 코드의 변경이 커 함수의 본문도 변경된 경우, 결함 주입 코드와 소스 코드의 이전 형상, 현재 형상을 비교하여 볼 수 있는 기능을 제공한다. 사용자는 결함 주입 코드를 새로운 테스트에 맞춰 직접 설계할 수 있다.
도 8에 도시된 바와 같이, 변경 범위 식별기는 기존 결함 주입 정보와 변경된 함수 정보에 기초하여 결함 주입 정보(코드)의 변경 필요 범위를 확인한다. 변경 필요 범위가 파악되면, 결함 주입 정보 위치 자동 변환기는 변환된 결함 주입 정보를 결함 주입 정보 검사기로 전달하고, 결함 주입 정보 검사기는 변경된 결함 주입 정보를 저장한다.
본 발명에 따른 단위 테스트 재사용 방법에 의하면, 사용자가 직접 변경된 함수에 대한 테스트를 다시 생성하지 않고도 기존 테스트를 수정하여 재활용할 수 있고, 테스트 시간이 단축되는 효과가 있다. 또한, 개발 도중에 진행할 수 있는 회귀 테스트에 빠르게 대처할 수 있다
위에서 설명한 단위 테스트 재설정 방법은 다양한 컴퓨터 수단을 통하여 수행될 수 있는 프로그램 명령 형태로 구현되어 컴퓨터 판독 가능한 기록 매체에 기록될 수 있다. 컴퓨터 판독 가능 기록 매체는 프로그램 명령, 데이터 파일, 데이터 구조 등을 단독으로 또는 조합하여 포함할 수 있다. 상기 매체에 기록되는 프로그램 명령은 본 발명을 위하여 특별히 설계되고 구성된 것들이거나 컴퓨터 소프트웨어 당업자에게 공지되어 사용 가능한 것일 수도 있다. 컴퓨터 판독 가능 기록 매체의 예에는 하드 디스크, 플로피 디스크 및 자기 테이프와 같은 자기 매체(magnetic media), CD-ROM, DVD와 같은 광기록 매체(optical media), 플롭티컬 디스크(floptical disk)와 같은 자기-광 매체(magneto-optical media), 및 롬(ROM), 램(RAM), 플래시 메모리 등과 같은 프로그램 명령을 저장하고 수행하도록 특별히 구성된 하드웨어 장치가 포함된다. 프로그램 명령의 예에는 컴파일러에 의해 만들어지는 것과 같은 기계어 코드뿐만 아니라 인터프리터 등을 사용해서 컴퓨터에 의해서 실행될 수 있는 고급 언어 코드를 포함한다. 상기된 하드웨어 장치는 본 발명의 동작을 수행하기 위해 하나 이상의 소프트웨어 모듈로서 작동하도록 구성될 수 있으며, 그 역도 마찬가지이다.
이상에서 실시 형태들에 설명된 특징, 구조, 효과 등은 본 발명의 하나의 실시 형태에 포함되며, 반드시 하나의 실시 형태에만 한정되는 것은 아니다. 나아가, 각 실시 형태에서 예시된 특징, 구조, 효과 등은 실시 형태들이 속하는 분야의 통상의 지식을 가지는 자에 의해 다른 실시 형태들에 대해서도 조합 또는 변형되어 실시 가능하다. 따라서 이러한 조합과 변형에 관계된 내용들은 본 발명의 범위에 포함되는 것으로 해석되어야 할 것이다. 또한, 이상에서 실시 형태를 중심으로 설명하였으나 이는 단지 예시일뿐 본 발명을 한정하는 것이 아니며, 본 발명이 속하는 분야의 통상의 지식을 가진 자라면 본 실시 형태의 본질적인 특성을 벗어나지 않는 범위에서 이상에 예시되지 않은 여러 가지의 변형과 응용이 가능함을 알 수 있을 것이다. 예를 들어, 실시 형태에 구체적으로 나타난 각 구성 요소는 변형하여 실시할 수 있는 것이다. 그리고 이러한 변형과 응용에 관계된 차이점들은 첨부된 청구 범위에서 규정하는 본 발명의 범위에 포함되는 것으로 해석되어야 할 것이다.

Claims (11)

  1. 기생성된 단위 테스트의 테스트 대상 함수 및 전역 변수의 변경 여부에 기초하여 상기 단위 테스트를 재설정 대상으로 식별하는 단계;
    재설정 대상이 된 상기 단위 테스트의 테스트 대상 함수를 변경하는 단계;
    상기 재설정 대상이 된 상기 단위 테스트의 전역 변수 정보를 변경하는 단계;
    변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 스텁 정보를 변경하는 단계; 및
    상기 변경된 테스트 대상 함수에 기초하여 상기 재설정 대상이 된 상기 단위 테스트의 결함 주입 정보를 변경하는 단계;를 포함하는 단위 테스트 재사용 방법.
  2. 제1항에 있어서,
    상기 식별하는 단계는,
    현재 소스 코드의 테스트 대상 함수와 상기 기생성된 단위 테스트의 테스트 대상 함수 사이의 유사도를 측정하는 단계; 및
    상기 유사도가 소정값 이상인 경우, 상기 단위 테스트를 재설정 대상으로 결정하는 단계;를 포함하는 단위 테스트 재사용 방법.
  3. 제2항에 있어서,
    상기 유사도를 측정하는 단계는,
    파라미터를 제외한 함수 이름, 함수가 있는 소스 코드의 파일 이름 및 함수가 있는 소스 코드의 파일 경로의 편집 거리에 기초하여 상기 유사도를 측정하는 단위 테스트 재사용 방법.
  4. 제3항에 있어서,
    상기 유사도를 측정하는 단계는,
    상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 서로 상이한 가중치를 부여하여 상기 유사도를 측정하는 단위 테스트 재사용 방법.
  5. 제4항에 있어서,
    상기 유사도를 측정하는 단계는,
    상기 파라미터를 제외한 함수 이름, 상기 함수가 있는 소스 코드의 파일 이름 및 상기 함수가 있는 소스 코드의 파일 경로의 편집 거리에 대하여 10:5:1의 비율로 가중치를 부여하여 상기 유사도를 측정하는 단위 테스트 재사용 방법.
  6. 제1항에 있어서,
    상기 테스트 대상 함수를 변경하는 단계는,
    상기 재설정 대상이 된 상기 단위 테스트와 연결된 신규 함수로부터 신규 단위 테스트를 생성하는 단위 테스트 재사용 방법.
  7. 제6항에 있어서,
    상기 테스트 대상 함수를 변경하는 단계는,
    상기 신규 단위 테스트의 테스트 대상 함수의 이름, 매개변수 및 반환값 중 적어도 하나를 상기 재설정 대상이 된 상기 단위 테스트에 대응하여 수정하는 단위 테스트 재사용 방법.
  8. 제1항에 있어서,
    상기 테스트 대상 함수의 전역 변수의 이름의 변경 여부를 판단하는 단계; 및
    상기 전역 변수의 이름이 변경된 경우, 변경된 전역 변수를 신규 단위 테스트에 대하여 일괄 변경하는 단계;를 더 포함하는 단위 테스트 재사용 방법.
  9. 제1항에 있어서,
    상기 스텁 정보를 변경하는 단계는,
    스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나의 변경 여부를 판단하는 단계; 및
    스텁 함수의 이름, 매개변수 및 반환값 중 적어도 하나가 변경된 경우, 변경된 테스트 대상 함수에 대응하도록 스텁 정보를 변환하는 단계;를 포함하는 단위 테스트 재사용 방법.
  10. 제1항에 있어서,
    상기 결함 주입 정보를 변경하는 단계는,
    상기 변경된 테스트 대상 함수의 변경 범위를 확인하는 단계; 및
    상기 변경 범위에 기초하여 상기 결함 주입 정보를 변경하는 단계;를 포함하는 단위 테스트 재사용 방법.
  11. 제1항 내지 제10항 중 어느 한 항에 기재된 단위 테스트 재사용 방법을 수행하기 위한 프로그램을 기록한 컴퓨터 판독 가능 기록매체.
PCT/KR2022/014113 2022-09-08 2022-09-21 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체 WO2024053772A1 (ko)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
KR1020220114501A KR20240035250A (ko) 2022-09-08 2022-09-08 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체
KR10-2022-0114501 2022-09-08

Publications (1)

Publication Number Publication Date
WO2024053772A1 true WO2024053772A1 (ko) 2024-03-14

Family

ID=90191397

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/KR2022/014113 WO2024053772A1 (ko) 2022-09-08 2022-09-21 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체

Country Status (2)

Country Link
KR (1) KR20240035250A (ko)
WO (1) WO2024053772A1 (ko)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1115695A (ja) * 1997-06-26 1999-01-22 Hitachi Ltd プログラムテストパターン自動生成システム
JP2009266045A (ja) * 2008-04-26 2009-11-12 Fujitsu Ltd テスト仕様作成支援プログラム及びテスト仕様作成支援方法
KR20160044305A (ko) * 2014-10-15 2016-04-25 삼성에스디에스 주식회사 코드의 단위 테스트를 위한 장치 및 방법
KR20180099192A (ko) * 2017-02-28 2018-09-05 슈어소프트테크주식회사 코드 커버리지 측정 방법 및 장치, 그리고 이를 실행하기 위한 프로그램을 기록한 컴퓨터로 판독가능한 기록매체
KR20210004656A (ko) * 2019-07-05 2021-01-13 현대자동차주식회사 차량 기능 테스트 장치 및 그 제어 방법

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR102377607B1 (ko) 2020-06-23 2022-03-23 (주)지산웨어 정보시스템을 설계하여 프로그램과 데이터베이스를 자동으로 생성하고 테스트를 자동 수행하는 소프트웨어 공학플랫폼

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH1115695A (ja) * 1997-06-26 1999-01-22 Hitachi Ltd プログラムテストパターン自動生成システム
JP2009266045A (ja) * 2008-04-26 2009-11-12 Fujitsu Ltd テスト仕様作成支援プログラム及びテスト仕様作成支援方法
KR20160044305A (ko) * 2014-10-15 2016-04-25 삼성에스디에스 주식회사 코드의 단위 테스트를 위한 장치 및 방법
KR20180099192A (ko) * 2017-02-28 2018-09-05 슈어소프트테크주식회사 코드 커버리지 측정 방법 및 장치, 그리고 이를 실행하기 위한 프로그램을 기록한 컴퓨터로 판독가능한 기록매체
KR20210004656A (ko) * 2019-07-05 2021-01-13 현대자동차주식회사 차량 기능 테스트 장치 및 그 제어 방법

Also Published As

Publication number Publication date
KR20240035250A (ko) 2024-03-15

Similar Documents

Publication Publication Date Title
WO2020141882A1 (ko) 설명 가능한 인공지능 모델링 및 시뮬레이션 시스템 및 방법
Verco et al. Software for detecting suspected plagiarism: Comparing structure and attribute-counting systems
WO2013077538A1 (ko) Api 기반 어플리케이션 분석 장치 및 방법
WO2021040265A1 (ko) 평균 반려율을 이용한 작업자 능숙도 측정 방법 및 장치
US8135571B2 (en) Validating manufacturing test rules pertaining to an electronic component
WO2013089340A1 (ko) 어플리케이션의 유사성 검출 장치 및 방법
WO2023287064A1 (ko) 이상 데이터 자동 검출 및 자동 라벨링 기술을 이용한 학습 데이터베이스 구축 방법 및 시스템
WO2019093675A1 (ko) 빅데이터 분석을 위한 데이터 병합 장치 및 방법
CN105760296A (zh) 自动化测试控制方法、装置及终端
WO2018016671A2 (ko) 보안 취약점 점검을 위한 위험성 코드 검출 시스템 및 그 방법
WO2019054613A1 (ko) 바이너리 파일에 기초하여 오픈소스 소프트웨어 패키지를 식별하는 방법 및 시스템
WO2020242108A1 (ko) 크라우드 소싱 기반 프로젝트의 특성에 따른 작업자 선별 방법
WO2017131325A1 (ko) 지식 베이스의 검증 및 교정 시스템 및 방법
WO2022114486A1 (ko) 어노테이션 자동 진단 시스템
WO2011065660A2 (ko) 계산 시뮬레이션 모사 시스템 및 그 방법
WO2013125866A1 (ko) 컴퓨터 시스템 및 시그니처검증서버
WO2024053772A1 (ko) 단위 테스트 재사용 방법 및 컴퓨터 판독 가능 기록매체
Avritzer et al. Reliability testing of rule-based systems
WO2022124573A1 (ko) 메뉴 구조 및 스크립트 내 키워드 기반 웹 사이트의 유사도 평가 방법
Verco et al. Plagiarism à la mode: a comparison of automated systems for detecting suspected plagiarism
US11086768B1 (en) Identifying false positives in test case failures using combinatorics
WO2014098372A1 (ko) 유해 사이트 수집 장치 및 방법
WO2009116748A2 (ko) 예약된 컴포넌트 컨테이너 기반 소프트웨어 개발 방법 및 장치
WO2023128320A1 (ko) 인공지능 검증 시스템 및 방법
WO2020235898A1 (ko) 크라우드 소싱 기반 프로젝트의 작업 단가 측정 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22958226

Country of ref document: EP

Kind code of ref document: A1