[Java] TDD study # 1 environment construction & first test-driven development (July 6th, 2020)

less than 1 minute read

I built a java environment.

Operating environment

  • visual studio code
  • windows10

vscode java environment construction

I saw the site below
https://qiita.com/takuma-jpn/items/b49785a314fb4db85775

Immediately struggling with Hello World!

A program that displays Hello World! in java ↓

Test.java



public class Test {
    public static void main(String[] args) {
        System.out.println("Hello.World!");
    }
}

Apparently it is necessary to match the file name and the class name. It was a swamp.
After that, create launch.json. Select a folder and make it a project (?)

TDD worked using maven

I saw the site below.
https://engineeringnote.hateblo.jp/entry/java/junit_with_maven_in_vscode

Notes
It is necessary to check maven in javahome from the settings.

I don’t understand java in the first place

How the class works

class.java


class AA{
    AA();        //constructor(?)
    void BB(){
    AA C = new AA();   //instance(?)
    C.BB()
    }
}

New knowledge (keyword)

–new operator
–assertEquals (argument 1, argument 2): Method to check if the arguments are equal

in conclusion

I tried to test with python with vscode (translate java test to python), but the environment construction was successful, but I gave up because I didn’t know how to write around class.
I will study TDD in java, which I am not used to for the time being.