Giter Club home page Giter Club logo

inflearn-nodejs-tdd's Introduction

inflearn-nodejs-tdd

인프런의 테스트주도개발(TDD)로 만드는 NodeJS API 서버 강좌를 학습하면서 정리한 프로젝트 입니다.

테스트 주도 개발(TDD)

개발을 할때 소스코드 부터 작성하는 것이 아닌 테스트 코드 부터 작성합니다. 작성한 테스트 코드를 통과시키면서 소스코드를 작성하는 것을 말합니다. 테스트 코드를 작성하게 되면 개발 생산성이 떨어지는 것이 맞지만, 작성한 코드를 서비스하는 시점에 직면하게 되면 유지보수하는 시간이 많이 감소하기 때문에 결과론적으로 개발자들의 시간을 많이 절약할 수 있으며 안정된 코드를 작성할 수 있습니다.

nodejs 에서는 TDD를 할 수 있는 3가지 라이브러리를 제공하고 있습니다.

  • 모카
  • 슈드
  • 슈퍼테스트

모카(mocha)

모카는 테스트 코드를 실행시켜주는 테스트 러너입니다.

  • 테스트 수트: 테스트 환경으로 모카에서는 describe() 함수로 구현합니다.
  • 테스트 케이스: 실제 테스트 코드를 말하며 모카에서는 it() 함수로 구현합니다.

슈드(Should)

노드 공식 문서에서는 assert를 사용하지 말고 서드파티 라이브러리를 사용하라고 한다.

  • Should는 검증(assertion) 라이브러리입니다.
  • 가독성 높은 테스트 코드를 만들 수 있습니다.

슈퍼테스트(Super Test)

  • 단위 테스트: 함수의 기능 테스트
  • 통합 테스트: API의 기능 테스트
  • 슈퍼 테스트는 익스프레스 통합 테스트용 라이브러리입니다.
  • 내부적으로 express server를 구동시켜 실제 요청을 보낸 뒤 결과를 검증합니다.

첫 API 테스트 만들기

  1. 성공
  • 유저 객체를 담은 배열로 응답한다.
  • 최대 limit 갯수만큼 응답한다.
  1. 실패
  • limit이 숫자형이 아니면 HTTP Response Code 400을 응답한다.
  • offset이 숫자형이 아니면 HTTP Response Code 400을 응답한다.

inflearn-nodejs-tdd's People

Contributors

binary-park avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.