Skip to content

Instantly share code, notes, and snippets.

@satob
Created December 4, 2021 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satob/2b7bdd2cfb09481f5acbc5f3bc8a61c3 to your computer and use it in GitHub Desktop.
Save satob/2b7bdd2cfb09481f5acbc5f3bc8a61c3 to your computer and use it in GitHub Desktop.
Class for code coverage test
package com.example;
public class Main {
public static void test() {
String hoge = getHoge();
String fuga = getFuga(10);
String piyo;
piyo = getPiyo(9,9);
piyo = getPiyo(11,9);
piyo = getPiyo(9,11);
piyo = getPiyo(11,11);
System.out.println("Hello World!:" + hoge + ":" + fuga + ":" + piyo);
}
public static String getHoge() {
return "HogeHoge";
}
public static String getFuga(int y) {
int x = 13;
String fuga = "Fuga";
if (x > 10) {
fuga = "Fuga x > 10";
}
if (x < 10) {
fuga = "x < 10";
}
if (x > 10 && y > 20) {
fuga = "Fuga x > 10 And y > 20";
}
if (x > 10 || y > 20) {
fuga = "Fuga x > 10 Or y > 20";
}
return fuga;
}
public static String getPiyo(int x, int y) {
String piyo = "Piyo";
if (x < 10 && y < 10) {
piyo = "Piyo x > 10 And y > 10";
} else if (x > 10 && y < 10) {
piyo = "Piyo x > 10 And y < 10";
} else if (x < 10 && y > 10) {
piyo = "Piyo x < 10 And y > 10";
} else if (x >= 10 && y >= 10) {
piyo = "Piyo x > 10 And y > 10";
}
return piyo;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment