org.evosuite.ConsoleProgressBar Maven / Gradle / Ivy
/**
* Copyright (C) 2010-2016 Gordon Fraser, Andrea Arcuri and EvoSuite
* contributors
*
* This file is part of EvoSuite.
*
* EvoSuite is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* EvoSuite is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with EvoSuite. If not, see .
*/
/**
*
*/
package org.evosuite;
import org.evosuite.rmi.MasterServices;
import org.evosuite.rmi.service.ClientState;
import org.evosuite.rmi.service.ClientStateInformation;
import org.evosuite.utils.Listener;
/**
*
* ConsoleProgressBar class.
*
*
* @author Gordon Fraser
*/
public class ConsoleProgressBar implements Listener{
private static final long serialVersionUID = 8930332599188240933L;
/**
*
* startProgressBar
*
*
*/
public static void startProgressBar() {
MasterServices.getInstance().getMasterNode().addListener(new ConsoleProgressBar());
}
@Override
public void receiveEvent(ClientStateInformation event) {
if(event.getState() != ClientState.SEARCH) {
return;
}
int percent = event.getProgress();
int coverage = event.getCoverage();
StringBuilder bar = new StringBuilder("[Progress:");
for (int i = 0; i < 30; i++) {
if (i < (int) (percent * 0.30)) {
bar.append("=");
} else if (i == (int) (percent * 0.30)) {
bar.append(">");
} else {
bar.append(" ");
}
}
bar.append(Math.min(100, percent) + "%] [Cov:");
for (int i = 0; i < 35; i++) {
if (i < (int) (coverage * 0.35)) {
bar.append("=");
} else if (i == (int) (coverage * 0.35)) {
bar.append(">");
} else {
bar.append(" ");
}
}
bar.append(coverage + "%]");
System.out.print("\r" + bar.toString());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy