- String - "Hello, world"
- Conditions - > , < , >=, <=, ==, !=
- Statements - if/else, switch
- Primitive - byte, short, int, long, float, double, boolean, char and test their edges.
- Loops - while loop and for loop
- Exception - TBD
- Design Pattern - TBD
more...
- 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);
}
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.
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.