Giter Club home page Giter Club logo

practice1's Introduction

Practice 1: One for you, and one for me

Given a name X, return a string with the message:

One for X, one for me.

However, if the name is missing, return the string:

One for you, one for me.

Here are some examples:

Name String to return
Ford One for Ford, one for me.
Marvin One for Marvin, one for me.
One for you, one for me.
Zaphod One for Zaphod, one for me.

Tips

Before you start, make sure you understand how to write code that can pass the test cases.

The practice tasks include multiple test cases. These cases are structured to support a useful process known as test-driven development (TDD). TDD involves repeating a structured cycle that helps programmers build complex functionality piece by piece rather than all at once. That cycle can be described as follows:

  1. Add a test that describes one piece of desired functionality your code is currently missing.
  2. Run the tests to verify that this newly-added test fails.
  3. Update your existing code until:
    • All the old tests continue to pass;
    • The new test also passes.
  4. Clean up your code, making sure that all tests continue to pass. This typically involves renaming variables, removing duplicated chunks of logic, removing leftover logging, etc.
  5. Return to step 1 until all desired functionality has been built!

The test files in this track contain all the tests your solution should pass to be considered valid. That doesn't immediately seem to be compatible with the cycle described above, in which tests are written one by one. However, the tool that we use to write our tests, JUnit, provides an @Ignore annotation that can be used to temporarily skip an already-written test. Using this annotation, we make sure that the test files we deliver to you satisfy the following rules:

  • The first test in any test file is not skipped by default.
  • All but the first test in any test file are skipped by default.

This allows you to simulate the TDD cycle by following these slightly modified steps:

  1. Run the tests to verify that at most one test currently fails.
  2. Update your existing code until all the non-skipped tests pass.
  3. Clean up your code, making sure that all non-skipped tests continue to pass.
  4. Remove the topmost @Ignore annotation in the test file.
  5. Return to step 1 until no tests are skipped and all tests pass!

Running the tests

You can run all the tests for an exercise by entering the following in your terminal:

$ gradle test

Use gradlew.bat if you're on Windows

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by removing the @Ignore("Remove to run test") annotation.

practice1's People

Contributors

cpen221org avatar gsathish 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.