Test cases pass when run individually and fail when run together

344 views Asked by At

Showing error in class where i am trying to get the values of static ArrayList<ArrayList> adjacent_list_train=new ArrayList<ArrayList>(); which is returning error like: java.lang.IndexOutOfBoundsException: Index 1 out of bounds for length 1. The issue is with the static variable?

class Node{

    
    static ArrayList<ArrayList<TrainVertices>> adjacent_list_train=new ArrayList<ArrayList<TrainVertices>>(); 
public void CList(){
      //error thrown at the following line
    if(FlightEdges.size>0) {
            if(!adjacent_list.isEmpty()) {
                for(int i=0;i<adjacent_list.size();i++) {
//error line
                    ArrayList<FlightEdges> fe_al=adjacent_list.get(i);
}
}

As per my observation it is something about static variable being accessed in multiple test class. As i am new to junit testing can you please tell what is wrong with the test class

0

There are 0 answers