GithubHelp home page GithubHelp logo

trambui09 / automated-testing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ada-c14/automated-testing

0.0 0.0 0.0 19 KB

Exercise: Practice TDD in a project with OOP

Ruby 92.93% Dockerfile 6.84% Shell 0.23%

automated-testing's Introduction

AutomatedTesting

Learning Goals

This exercise is designed to enable you to:

  • Learn Minitest spec-style syntax
  • Learn to design spec-style tests to adequately ensure a class performs as expected.

Overview

You've been introduced to TDD and testing. Now we're going to be writing tests. We'll start by writing code to satisfy existing tests, and then fill in empty specs to write our own tests, finish by designing a few tests yourself.

File Structure

Your project has the following Structure

Rakefile
-lib
  -card.rb
  -deck.rb
-test
  -card_test.rb
  -deck_test.rb
  -test_helper.rb

The lib folder contains the two classes you will be working with, card.rb and deck.rb. These two classes represent playing cards and a deck for use in a card game app. We will be writing these classes in a TDD fashion.

The test folder contains the test cases for each class. You will start by making the existing tests pass, in Wave 2, begin adding your own tests.

The Rakefile enables you to use the rake command to run the automated tests. It will run minitest through all the files in the test folder ending with _test.rb.

Wave 1 - Getting Card To Pass

Right now you have a Card class and an assortment of tests. Your first job is to read the first set of tests and write the Card class to satisfy them.

Remember you can run the tests with the $ rake command.

Wave 2 - Filling In Tests

You'll have noticed that some of the it blocks are empty. You'll now fill in tests to check the given items.

Wave 3 - Spec'ing out the Deck class

Now you'll write code to spec out the Deck class and write the implementation.

At a minimum a Deck should:

  • Be able to be instantiated.
  • Be created with 52 Card objects as attributes.
  • Have a shuffle method
    • Don't try to test for randomness at this point, it's tough to test for something random, just make sure the method can be called.
  • Have a method called draw which removes a Card from the Deck and returns the removed Card.
  • Have a count method which returns the number of cards in the Deck.

You should have a minimum of 5 tests.

Think about:

  • What edge cases could exist when using a deck of cards?
  • What should be true of the cards in a Deck?
  • What is the expected behavior of the draw method?

automated-testing's People

Contributors

cheezitman avatar kaidamasaki avatar trambui09 avatar tildeee 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.