SlideShare a Scribd company logo
1 of 59
Download to read offline
테알못 신입은 어떻게 테스트를 시작했을까?
안녕하세요!!!
/ / 3 ) 1 /0 31
. ( / . 31 . 9
:
@ @
: :
D T8
5 ,
. 5
D +)) (+ 52 T8
1D 0
D +
O 8C +))
,
*
*
§
§
§
§
§
CONTENTS
R R ).
J .(
).
) ( R U
NOTICE
Red Green
Refactor
TDD
(실패) (성공)
(성공)
코드가 없어서
Test Last
Red Green
Refactor
(실패) (성공)
(성공)
버그가 있어서
*TDD아님
Code easy
to test
Code hard
to test
Production code
(
YES
NO
D )
,
// YY. M. DD. -> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.');
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return splitArray.join('').replace(/ /gi, '');
}
Code easy
to test
.
// dateHelper.test.js
describe('formatDateForQueryString ', () => {
describe('YY. M. DD. , ', () => {
test('YYMMDD .', () => {
const actual = formatDateForQueryString('18. 1. 10.');
expect(actual).toBe('180110');
});
});
});
// YY. M. DD.-> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.');
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return splitArray.join('').replace(/ /gi, '');
}
Code easy
to test
. .
// dateHelper.test.js
describe('formatDateForQueryString ', () => {
describe('YY. M. DD. , ', () => {
test('YYMMDD .', () => {
const actual = formatDateForQueryString('18. 1. 10.');
expect(actual).toBe('180110');
});
});
});
// YY. M. DD.-> YYMMDD
export function formatDateForQueryString(dateString) {
const splitArray = dateString.split('.');
splitArray.map((el, i, arr) => {
arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el;
});
return splitArray.join('').replace(/ /gi, '');
}
Code easy
to test
export function formatDateForQueryString(dateString) {
return `${dateString} `
.split('. ')
.map(x => (x.length === 1 ? `0${x}` : x))
.join('');
}
Refactor
( *
?
Code easy
to test
Code hard
to test
Production code
X )
) *
. ?
. .
* ) ) (
Code hard
to test
easy
hard
easy
! !
Refactor
Red
Green
or
class RegistrationFormContainer extends Component {
/* */
handleSubmit = async () => {
const { validValues } = this.props.form;
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username: validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
try {
await postRegisterRequest(command);
this.closeModal();
} catch (err) {
Modal.error({ /* ... */ });
}
};
render() { /* ... */ }
}
}
Code hard
to test
I *() A
A 2
. 1
function formatRegisterCommand() {
const { validValues } = this.props.form;
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username:
validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
return command;
}
export default formatRegisterCommand;
import formatRegisterCommand /* ... */
describe('formatRegisterCommand ', () => {
test(' .', () => {
expect(formatRegisterCommand).not.toThrowError();
});
});
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand() {
const { validValues } = this.props.form;
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username:
validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
return command;
}
export default formatRegisterCommand;
import formatRegisterCommand /* ... */
describe('formatRegisterCommand ', () => {
test(' ) .', () => {
expect(formatRegisterCommand).not.toThrowError();
});
});
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js
=(
formatRegisterCommand.test.js
function formatRegisterCommand(validValues={}){
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username:
validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
return command;
}
export default formatRegisterCommand;
import formatRegisterCommand /* ... */
describe('formatRegisterCommand ', () => {
test(' .', () => {
expect(formatRegisterCommand).not.toThrowError();
});
});
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand(validValues={}){
const phone = validValues.phone
? '+82' + validValues.phone.slice(1)
: null;
const command = {
username:
validValues.username || validValues.email,
email: validValues.email,
phone: phone,
};
return command;
}
export default formatRegisterCommand;
/* ... */
describe(' , ', () => {
const param = {
username: 'user',
email: 'user@email.com',
phone: '01012345678',
agreement: [true, true, true],
};
describe('username ', () => {
test(' username .’,() => {
const actual = formatRegisterCommand(param);
expect(actual.username).toBe(param.username);
});
});
});
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
Red Green
Refactor
TDD
/* ... */
describe(' agreement ', () => {
test(' false false .', () => {
const actual = formatRegisterCommand({
...param,
agreement: [true, true, false],
});
expect(actual).toBe(false);
});
});
/* ... */
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand(source = {}) {
const { username, email, phone } = source;
return {
username: username || email,
email,
phone: phone ? `+82${phone.slice(1)}` : null,
};
}
export default formatRegisterCommand;
/* ... */
describe(' agreement ', () => {
test(' false false .', () => {
const actual = formatRegisterCommand({
...param,
agreement: [true, true, false],
});
expect(actual).toBe(false);
});
});
/* ... */
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand(source = {}) {
const { username, email, phone } = source;
if (source.agreement.some(agree => !agree)) {
return false;
}
return {
username: username || email,
email,
phone: phone ? `+82${phone.slice(1)}` : null,
};
}
export default formatRegisterCommand;
if (source.agreement.some(agree => !agree)) {
return false;
}
X * D
* 1 (
. .
* ) ) (
*
2* +)
.
*
T
!
/* ... */
describe('formatRegisterCommand ', () => {
test(' .', () => {
expect(formatRegisterCommand).not.toThrowError();
});
});
describe(' agreement ', () => {
test(' false false .', () => {
const actual = formatRegisterCommand({
...param,
agreement: [true, true, false],
});
expect(actual).toBe(false);
});
});
/* ... */
UTF-8 LF JavaScript React Prettier:
formatRegisterCommand.js formatRegisterCommand.test.js
function formatRegisterCommand(source = {}) {
const { username, email, phone } = source;
if (source.agreement.some(agree => !agree)) {
return false;
}
return {
username: username || email,
email,
phone: phone ? `+82${phone.slice(1)}` : null,
};
}
export default formatRegisterCommand;
if (source.agreement.some(agree => !agree)) {
return false;
}
FAIL src/business/formatRegisterCommand.test.js
● formatRegisterCommand › .
expect(function).not.toThrowError()
Expected the function not to throw an error.
Instead, it threw:
TypeError: Cannot read property 'some' of undefined
at formatRegisterCommand (src/business/formatRegisterCommand.js:9:17)
/* ... */
formatRegisterCommand
✓ .
,
UTF-8 LF JavaScript React Prettier:
,
&
PASS src/business/formatRegisterCommand.test.js
formatRegisterCommand
✓ .
,
username
✓ username .
✓ username falsy value email
email
✓ email .
phone
✓ phone 0 +82 .
agreement
✓ false false .
PASS src/business/formatRegisterCommand.test.js
formatRegisterCommand
✓ .
a e , a
username
✓ username f - f .
✓ username falsy value email
email
✓ email f - f .
phone
✓ phone - 0 +82 - f .
- agreement
✓ e false b - false .
a
)) (
a
formatRegisterCommand.js
function formatRegisterCommand(source = {}) {
const { username, email, phone } = source;
const agreement = source.agreement || [];
if (agreement.some(agree => !agree))
return false;
return {
username: username || email,
email,
phone: phone
? `+82${phone.slice(1)}`
: null,
};
}
export default formatRegisterCommand;
UTF-8 LF JavaScript React Prettier:
&
*
D ≤ D
* 1
&
*
*
.
/88 0 8/ 1. 46- 6. 4 / 8 8-- 42:.
( .
)
PASS src/components/headers/InventoryHeader/InventoryHeader.test.js
InventoryHeader
1 Col
√ Select . 1 . (1ms)
√ defaultValue both. . (1ms)
Option components:
√ 2 , Option . (2ms)
√ Option value prop text . (1ms)
2 Col
√ 2 . (1ms)
√ Button 1 . . (1ms)
√ Modal 1 . . (2ms)
√ Dropdown 1 .
( !
)
PASS src/components/common/DescriptionItem/DescriptionItem.test.js
DescriptionItem title conten props ,
√ div . (15ms)
√ div p , 2 .
) *
) (
<
,
(
describe('content falsy value ,', () => {
test(' "N/A" .', () => {
const props = { content: '' };
const wrapper = shallow(<DescriptionItem {...props} />);
expect(wrapper.childAt(1).text()).toBe('N/A');
});
});
O
M
M D
<div>
<p>
Text
<h1>
Text
<div>
<div>
Text
<h1>
<p>
Text
describe('content falsy value ,', () => {
test(' "N/A" .', () => {
const props = { content: '' };
const wrapper = shallow(<DescriptionItem {...props} />);
expect(wrapper.contains('N/A')).toBe(true);
});
});
( ( )
(
<div>
<p>
Text
<h1>
Text
<div>
<div>
Text
<h1>
<p>
Text
//...
test('div .', () => {
expect(wrapper.childAt(1).type()).toBeUndefined();
});
//...
});
//...
,
/ .
describe('ProductList component ', () => {
test('should display the product name in each `<li>` element', () => {
const fixture = [
{ id: 1, name: 'Product 1’ },
{ id: 2, name: 'Product 2’ },
{ id: 3, name: 'Product 3’ },
];
const wrapper = shallow(<ProductList products={fixture} />);
const firstElement = wrapper.find('li').first();
expect(firstElement.contains(fixture[0].name)).toBe(true);
});
});
,
describe('ProductList component ', () => {
test('should display the product name in first `<li>` element', () => {
const fixture = [
{ id: 1, name: 'Product 1’ },
{ id: 2, name: 'Product 2’ },
{ id: 3, name: 'Product 3’ },
];
const wrapper = shallow(<ProductList products={fixture} />);
const firstElement = wrapper.find('li').first();
expect(firstElement.contains(fixture[0].name)).toBe(true);
});
});
export default class ProductList extends Component {
render() {
return (
<ul>{this.props.products.map(product => <li>{product.name}</li>)}</ul>
);
}
}
,
.
. .
,
, !
export default class ProductList extends Component {
render() {
return (
<ul><li>{products[0].name}</li></ul>
);
}
}
describe('phone ', () => {
const param = {
username: 'user',
email: 'user@email.com',
phone: '01012345678',
agreement: [true, true, true],
};
test(' 0 +82 .', () => {
const actual = formatRegisterCommand(param);
expect(actual.phone).toBe('+821012345678');
});
});
{
"brandId": "3de0af54-3eb5-48a6-81b3-0618b7f6c6d1",
"products": [
{
"id": "b0dc7f67-258a-44be-9d58-cc033c5b2100",
"name": "Pure Soup - Liquid",
"color": ["Blue", "Green", "Pink"],
"price": "$2.99",
"channels": [
{
"id": "688b0956-ab2b-4cc4-826d-66e29aa6ad2c",
"name": "Amazon"
},
{
"id": "c12cba69-8a51-40b9-80b5-122ffff1e378",
"name": "ebay"
},
{
"id": "5fc2502e-b6eb-42c6-af40-1de5fc49179c",
"name": "FlipKart"
}
]
},
...
?
ph g C LH C C l
l i s ph
e n LH o u
o ) . ( . .. ( . , )
l
감사합니다

More Related Content

Recently uploaded

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 

Recently uploaded (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

[OKKYCON] 이혜승 - 테알못 신입은 어떻게 테스트를 시작했을까?

  • 1. 테알못 신입은 어떻게 테스트를 시작했을까?
  • 2. 안녕하세요!!! / / 3 ) 1 /0 31 . ( / . 31 . 9 : @ @ : :
  • 3. D T8 5 , . 5 D +)) (+ 52 T8 1D 0 D + O 8C +))
  • 4.
  • 5. ,
  • 7. R R ). J .( ). ) ( R U NOTICE
  • 8.
  • 9. Red Green Refactor TDD (실패) (성공) (성공) 코드가 없어서 Test Last Red Green Refactor (실패) (성공) (성공) 버그가 있어서
  • 11. Code easy to test Code hard to test Production code ( YES NO D ) ,
  • 12. // YY. M. DD. -> YYMMDD export function formatDateForQueryString(dateString) { const splitArray = dateString.split('.'); splitArray.map((el, i, arr) => { arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el; }); return splitArray.join('').replace(/ /gi, ''); } Code easy to test . // dateHelper.test.js describe('formatDateForQueryString ', () => { describe('YY. M. DD. , ', () => { test('YYMMDD .', () => { const actual = formatDateForQueryString('18. 1. 10.'); expect(actual).toBe('180110'); }); }); });
  • 13. // YY. M. DD.-> YYMMDD export function formatDateForQueryString(dateString) { const splitArray = dateString.split('.'); splitArray.map((el, i, arr) => { arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el; }); return splitArray.join('').replace(/ /gi, ''); } Code easy to test . . // dateHelper.test.js describe('formatDateForQueryString ', () => { describe('YY. M. DD. , ', () => { test('YYMMDD .', () => { const actual = formatDateForQueryString('18. 1. 10.'); expect(actual).toBe('180110'); }); }); });
  • 14. // YY. M. DD.-> YYMMDD export function formatDateForQueryString(dateString) { const splitArray = dateString.split('.'); splitArray.map((el, i, arr) => { arr[i] = el.replace(/ /gi, '').length === 1 ? '0' + el : el; }); return splitArray.join('').replace(/ /gi, ''); } Code easy to test export function formatDateForQueryString(dateString) { return `${dateString} ` .split('. ') .map(x => (x.length === 1 ? `0${x}` : x)) .join(''); } Refactor
  • 15. ( * ? Code easy to test Code hard to test Production code X ) ) * . ? . . * ) ) (
  • 16. Code hard to test easy hard easy ! ! Refactor Red Green or
  • 17. class RegistrationFormContainer extends Component { /* */ handleSubmit = async () => { const { validValues } = this.props.form; const phone = validValues.phone ? '+82' + validValues.phone.slice(1) : null; const command = { username: validValues.username || validValues.email, email: validValues.email, phone: phone, }; try { await postRegisterRequest(command); this.closeModal(); } catch (err) { Modal.error({ /* ... */ }); } }; render() { /* ... */ } } } Code hard to test I *() A A 2 . 1
  • 18. function formatRegisterCommand() { const { validValues } = this.props.form; const phone = validValues.phone ? '+82' + validValues.phone.slice(1) : null; const command = { username: validValues.username || validValues.email, email: validValues.email, phone: phone, }; return command; } export default formatRegisterCommand; import formatRegisterCommand /* ... */ describe('formatRegisterCommand ', () => { test(' .', () => { expect(formatRegisterCommand).not.toThrowError(); }); }); UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js
  • 19. function formatRegisterCommand() { const { validValues } = this.props.form; const phone = validValues.phone ? '+82' + validValues.phone.slice(1) : null; const command = { username: validValues.username || validValues.email, email: validValues.email, phone: phone, }; return command; } export default formatRegisterCommand; import formatRegisterCommand /* ... */ describe('formatRegisterCommand ', () => { test(' ) .', () => { expect(formatRegisterCommand).not.toThrowError(); }); }); UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js =( formatRegisterCommand.test.js
  • 20. function formatRegisterCommand(validValues={}){ const phone = validValues.phone ? '+82' + validValues.phone.slice(1) : null; const command = { username: validValues.username || validValues.email, email: validValues.email, phone: phone, }; return command; } export default formatRegisterCommand; import formatRegisterCommand /* ... */ describe('formatRegisterCommand ', () => { test(' .', () => { expect(formatRegisterCommand).not.toThrowError(); }); }); UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js
  • 21. function formatRegisterCommand(validValues={}){ const phone = validValues.phone ? '+82' + validValues.phone.slice(1) : null; const command = { username: validValues.username || validValues.email, email: validValues.email, phone: phone, }; return command; } export default formatRegisterCommand; /* ... */ describe(' , ', () => { const param = { username: 'user', email: 'user@email.com', phone: '01012345678', agreement: [true, true, true], }; describe('username ', () => { test(' username .’,() => { const actual = formatRegisterCommand(param); expect(actual.username).toBe(param.username); }); }); }); UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js
  • 22.
  • 23.
  • 25. /* ... */ describe(' agreement ', () => { test(' false false .', () => { const actual = formatRegisterCommand({ ...param, agreement: [true, true, false], }); expect(actual).toBe(false); }); }); /* ... */ UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js function formatRegisterCommand(source = {}) { const { username, email, phone } = source; return { username: username || email, email, phone: phone ? `+82${phone.slice(1)}` : null, }; } export default formatRegisterCommand;
  • 26. /* ... */ describe(' agreement ', () => { test(' false false .', () => { const actual = formatRegisterCommand({ ...param, agreement: [true, true, false], }); expect(actual).toBe(false); }); }); /* ... */ UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js function formatRegisterCommand(source = {}) { const { username, email, phone } = source; if (source.agreement.some(agree => !agree)) { return false; } return { username: username || email, email, phone: phone ? `+82${phone.slice(1)}` : null, }; } export default formatRegisterCommand; if (source.agreement.some(agree => !agree)) { return false; }
  • 27.
  • 28. X * D * 1 ( . . * ) ) ( * 2* +) . * T
  • 29.
  • 30.
  • 31. !
  • 32. /* ... */ describe('formatRegisterCommand ', () => { test(' .', () => { expect(formatRegisterCommand).not.toThrowError(); }); }); describe(' agreement ', () => { test(' false false .', () => { const actual = formatRegisterCommand({ ...param, agreement: [true, true, false], }); expect(actual).toBe(false); }); }); /* ... */ UTF-8 LF JavaScript React Prettier: formatRegisterCommand.js formatRegisterCommand.test.js function formatRegisterCommand(source = {}) { const { username, email, phone } = source; if (source.agreement.some(agree => !agree)) { return false; } return { username: username || email, email, phone: phone ? `+82${phone.slice(1)}` : null, }; } export default formatRegisterCommand; if (source.agreement.some(agree => !agree)) { return false; } FAIL src/business/formatRegisterCommand.test.js ● formatRegisterCommand › . expect(function).not.toThrowError() Expected the function not to throw an error. Instead, it threw: TypeError: Cannot read property 'some' of undefined at formatRegisterCommand (src/business/formatRegisterCommand.js:9:17) /* ... */ formatRegisterCommand ✓ . , UTF-8 LF JavaScript React Prettier:
  • 33. ,
  • 34. &
  • 35. PASS src/business/formatRegisterCommand.test.js formatRegisterCommand ✓ . , username ✓ username . ✓ username falsy value email email ✓ email . phone ✓ phone 0 +82 . agreement ✓ false false .
  • 36. PASS src/business/formatRegisterCommand.test.js formatRegisterCommand ✓ . a e , a username ✓ username f - f . ✓ username falsy value email email ✓ email f - f . phone ✓ phone - 0 +82 - f . - agreement ✓ e false b - false . a )) ( a
  • 37. formatRegisterCommand.js function formatRegisterCommand(source = {}) { const { username, email, phone } = source; const agreement = source.agreement || []; if (agreement.some(agree => !agree)) return false; return { username: username || email, email, phone: phone ? `+82${phone.slice(1)}` : null, }; } export default formatRegisterCommand; UTF-8 LF JavaScript React Prettier:
  • 38. &
  • 39. * D ≤ D * 1 &
  • 40. * *
  • 41. .
  • 42. /88 0 8/ 1. 46- 6. 4 / 8 8-- 42:. ( . )
  • 43.
  • 44. PASS src/components/headers/InventoryHeader/InventoryHeader.test.js InventoryHeader 1 Col √ Select . 1 . (1ms) √ defaultValue both. . (1ms) Option components: √ 2 , Option . (2ms) √ Option value prop text . (1ms) 2 Col √ 2 . (1ms) √ Button 1 . . (1ms) √ Modal 1 . . (2ms) √ Dropdown 1 . ( ! )
  • 45. PASS src/components/common/DescriptionItem/DescriptionItem.test.js DescriptionItem title conten props , √ div . (15ms) √ div p , 2 . ) * ) ( < , (
  • 46. describe('content falsy value ,', () => { test(' "N/A" .', () => { const props = { content: '' }; const wrapper = shallow(<DescriptionItem {...props} />); expect(wrapper.childAt(1).text()).toBe('N/A'); }); }); O M M D <div> <p> Text <h1> Text <div> <div> Text <h1> <p> Text
  • 47. describe('content falsy value ,', () => { test(' "N/A" .', () => { const props = { content: '' }; const wrapper = shallow(<DescriptionItem {...props} />); expect(wrapper.contains('N/A')).toBe(true); }); }); ( ( ) ( <div> <p> Text <h1> Text <div> <div> Text <h1> <p> Text
  • 48. //... test('div .', () => { expect(wrapper.childAt(1).type()).toBeUndefined(); }); //... }); //... , / .
  • 49. describe('ProductList component ', () => { test('should display the product name in each `<li>` element', () => { const fixture = [ { id: 1, name: 'Product 1’ }, { id: 2, name: 'Product 2’ }, { id: 3, name: 'Product 3’ }, ]; const wrapper = shallow(<ProductList products={fixture} />); const firstElement = wrapper.find('li').first(); expect(firstElement.contains(fixture[0].name)).toBe(true); }); }); ,
  • 50. describe('ProductList component ', () => { test('should display the product name in first `<li>` element', () => { const fixture = [ { id: 1, name: 'Product 1’ }, { id: 2, name: 'Product 2’ }, { id: 3, name: 'Product 3’ }, ]; const wrapper = shallow(<ProductList products={fixture} />); const firstElement = wrapper.find('li').first(); expect(firstElement.contains(fixture[0].name)).toBe(true); }); });
  • 51. export default class ProductList extends Component { render() { return ( <ul>{this.props.products.map(product => <li>{product.name}</li>)}</ul> ); } } , . . .
  • 52. , , ! export default class ProductList extends Component { render() { return ( <ul><li>{products[0].name}</li></ul> ); } }
  • 53.
  • 54. describe('phone ', () => { const param = { username: 'user', email: 'user@email.com', phone: '01012345678', agreement: [true, true, true], }; test(' 0 +82 .', () => { const actual = formatRegisterCommand(param); expect(actual.phone).toBe('+821012345678'); }); });
  • 55. { "brandId": "3de0af54-3eb5-48a6-81b3-0618b7f6c6d1", "products": [ { "id": "b0dc7f67-258a-44be-9d58-cc033c5b2100", "name": "Pure Soup - Liquid", "color": ["Blue", "Green", "Pink"], "price": "$2.99", "channels": [ { "id": "688b0956-ab2b-4cc4-826d-66e29aa6ad2c", "name": "Amazon" }, { "id": "c12cba69-8a51-40b9-80b5-122ffff1e378", "name": "ebay" }, { "id": "5fc2502e-b6eb-42c6-af40-1de5fc49179c", "name": "FlipKart" } ] }, ...
  • 56. ?
  • 57. ph g C LH C C l l i s ph e n LH o u o ) . ( . .. ( . , ) l
  • 58.