Giter Club home page Giter Club logo

unit-test-comprehensive-2019-6-14-6-31-33-679's Introduction

Unit Test Comprehensive

Business Requirement

There is a game that realizes guessing numbers. There are four grids in the game, each with a number from 0 to 9, and the numbers for any two grids are different. You have 6 chances to guess. If you guess right, then you win; otherwise, you fail. Each time when you guess, you need to input 4 numbers in sequence. The program will give you feedback of xAxB according to the guessing situation. The number before A represents the number of correct position and number, and the number before B represents the number of correct number but wrong position.

For example: the answer is 1 2 3 4, then there are the following outputs based on different inputs

Example

The answer is 1 2 3 4, then there are the following outputs based on different inputs

Input      Output             Instruction
1 5 6 7      1A0B                 1 correct
2 4 7 8      0A2B                 2 and 4 wrong position 
0 3 2 4      1A2B                 4 correct,2 and 3 wrong position
5 6 7 8      0A0B                 all wrong
4 3 2 1      0A4B                 4 numbers position wrong
1 2 3 4      4A0B                 win, all correct
1 1 2 3    Wrong Input,Input again
1 2        Wrong Input,Input again

The answer is randomly generated at the beginning of the game. There are only 6 chances for input. Each time when you guess, the program should give the results of the current guess, as well as all previously guessed numbers and results for the player's reference. The input interface is Console (console) to avoid too many interface codes that are not related to the problem. When inputting, separate the numbers with spaces.

Practice Requirement:

  • ** Design and write test cases after clearly understanding the requirements**
  • ** Complete tests in the existing test file and ensure that the test coverage of the test category of this test file is 100%**
  • Unit testing should cover all core business logic
  • Make unit test refactoring with small steps
  • Denominate meaningful names for unit tests and methods
  • ** Submit code in small steps with a comment on meaning **

Environment Requirement

  • Java 8
  • Intellj IDEA

How to Start

  • You can fork the following github repository as starting point
  • Run Main.java file under the src/main catalogue of project
    • If Guess Number Game, You have 6 chances to guess! appears, then it means the project initialization is successful
  • Complete unit test on corresponding file under the src/test catalogue of project

How to Test

  • Implement ./gradlew clean test under root catalogue and view test result

Practice Output && Submit

  • You should implement the test code and push your repo to github repo named unit-test-comprehensive.
  • Commit your repostory link to complete this Question.

unit-test-comprehensive-2019-6-14-6-31-33-679's People

Contributors

linwenjun avatar

Watchers

James Cloos 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.