/JavaTDD

A repo to encourage beginner or improve your coding skill with Java Test Driven Development.You are welcome to contribute or file issues

Primary LanguageJava

JavaTDD

Issues GitHub pull requests

Table of contents

Java fundamentals

  1. String - "Hello, world"
  2. Conditions - > , < , >=, <=, ==, !=
  3. Statements - if/else, switch
  4. Primitive - byte, short, int, long, float, double, boolean, char and test their edges.
  5. Loops - while loop and for loop
  6. Exception - TBD
  7. Design Pattern - TBD

more...

Code expected

  • Proper naming for variables, avoid using i,v,k...etc. The variable name should be self explanatory.
  • Proper names for files
  • Follow unit tests naming conventions - MethodName_StateUnderTest_ExpectedBehavior
    String hello(String name) {
        return "Hello World " + name;
    }

    @Test
    void hello_InputName_HelloWorldWithName() {
        String result = helloWorld.hello("Name");
        assertEquals("Hello World Name", result);
    }

Import and Execute

It's a Gradle project, can be simply imported by any IDE such as Eclipse, Intellij.
Firstly , git clone https://github.com/fengyuanyang/JavaTDD.git
Secondly, open with build.gradle file. IDE should do the rest of importing and dependencies download.
Thirdly, open any test file you would like to execute, run it.

Background

As time goes by, project is getter big, people who wrote that code might have been missing.
How could I refactor those code I don't even know why the logic like this.
TDD is a perfect way for me to refactor or start the codes. What I need to do is trying my best to pass all the tests.