#My Test Cases Are Being Ignored (how to fix?)
7 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @wild coral! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Let me Post My Code from both Test Case Class and Person Class
import java.io.File;
import java.util.Scanner;
public class Person {
private int[] aCount,bCount,bPercent;
private String name, answers,type;
// Constructor
public Person(String name,String answers){
this.name = name;
this.answers = answers;
this.aCount = new int[4];
this.bCount = new int[4];
this.bPercent = new int[4];
this.type = "";
storeData();
bPercentage();
personality();
}
public void storeData(){
for(int i = 0; i < answers.length(); i++){
char choice = answers.charAt(i);
switch(i % 4){
case 0:
if('A' == choice || 'a' == choice) aCount[0]++;
else bCount[0]++;
break;
case 1:
if('A' == choice || 'a' == choice) aCount[1]++;
else bCount[1]++;
break;
case 2:
if('A' == choice || 'a' == choice) aCount[2]++;
else bCount[2]++;
break;
case 3:
if('A' == choice || 'a' == choice) aCount[3]++;
else bCount[3]++;
break;
}
}
}
public void bPercentage(){
for(int i = 0; i < bPercent.length; i++){
bPercent[i] = bCount[i] / (aCount[i] + bCount[i]) * 100;
}
}
public void personality(){
for(int i = 0; i < bPercent.length; i++){
switch(i % 4){
case 0:
type += (bPercent[i] >= 90) ? "I" : "E";
if(bPercent[i] == 50){
type += "X";
}
break;
case 1:
type += (bPercent[i] >= 90) ? "N" : "S";
if(bPercent[i] == 50){
type += "X";
}
break;
case 2:
type += (bPercent[i] >= 90) ? "F" : "T";
if(bPercent[i] == 50){
type += "X";
}
break;
case 3:
type += (bPercent[i] >= 90) ? "P" : "J";
if(bPercent[i] == 50){
type += "X";
}
break;
}
}
}
public void main(){
Scanner in = new Scanner(System.in);
File answers;
System.out.print("Enter file name: ");
answers = new File(in.nextLine());
while (!answers.exists()) {
System.out.print("File not found. Try again: ");
answers = new File(in.nextLine());
}
}
}
For Example this is one of the test cases that's being ignored.
@Test
public void aTestBettyAName() {
System.out.println("Betty Test Name");
String name = "Betty Boop:";
assertEquals(name, in.nextLine().trim());
}