SlideShare a Scribd company logo
테알못 신입은 어떻게 테스트를 시작했을까?
안녕하세요!!!
/ / 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

Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
abdulrafaychaudhry
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
Shane Coughlan
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
abdulrafaychaudhry
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 

Recently uploaded (20)

Game Development with Unity3D (Game Development lecture 3)
Game Development  with Unity3D (Game Development lecture 3)Game Development  with Unity3D (Game Development lecture 3)
Game Development with Unity3D (Game Development lecture 3)
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
openEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain SecurityopenEuler Case Study - The Journey to Supply Chain Security
openEuler Case Study - The Journey to Supply Chain Security
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)Introduction to Pygame (Lecture 7 Python Game Development)
Introduction to Pygame (Lecture 7 Python Game Development)
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 

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 Hubspot
Marius 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 ChatGPT
Expeed 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 Engineerings
Pixeldarts
 
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
ThinkNow
 
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
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
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
Neil 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 2024
Albert 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 Insights
Kurio // 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 2024
Search 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 summary
SpeakerHub
 
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 Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit 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 management
MindGenius
 
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.