PatchImplementationTest: Don't immediately fail upon finding an error

This commit is contained in:
Max Weber
2019-01-15 22:14:43 -07:00
parent a225789f0c
commit c017bd4a36
3 changed files with 21 additions and 9 deletions

View File

@@ -21,7 +21,8 @@
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/package net.runelite.client.plugins.timetracking.farming;
*/
package net.runelite.client.plugins.timetracking.farming;
import org.junit.Test;

View File

@@ -26,11 +26,16 @@ package net.runelite.client.plugins.timetracking.farming;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
import static org.hamcrest.Matchers.*;
public class PatchImplementationTest
{
@Rule
public ErrorCollector collector = new ErrorCollector();
@Test
public void testRange()
{
@@ -43,20 +48,20 @@ public class PatchImplementationTest
if (s != null)
{
String pfx = impl.name() + "[" + i + "]";
Assert.assertNotNull(pfx + ": null cropState", s.getCropState());
Assert.assertNotNull(pfx + ": null produce", s.getProduce());
Assert.assertTrue(pfx + ": " + s.getStage() + " < 0", s.getStage() >= 0);
collector.checkThat(pfx + ": cropState", s.getCropState(), notNullValue());
collector.checkThat(pfx + ": produce", s.getProduce(), notNullValue());
collector.checkThat(pfx + ": negative stage", s.getStage(), greaterThanOrEqualTo(0));
int stages = s.getProduce().getStages();
if (s.getCropState() == CropState.HARVESTABLE)
{
stages = s.getProduce().getHarvestStages();
}
Assert.assertTrue(pfx + ": " + s.getStage() + " >= " + stages, s.getStage() < stages);
collector.checkThat(pfx + ": out of bounds stage", s.getStage(), lessThan(stages));
if (s.getCropState() == CropState.DEAD || s.getCropState() == CropState.DISEASED)
{
Assert.assertTrue(pfx + ": dead seed", s.getStage() > 0);
collector.checkThat(pfx + ": dead seed", s.getStage(), greaterThan(0));
}
if (s.getCropState() == CropState.GROWING && s.getProduce() != Produce.WEEDS)
if (s.getCropState() == CropState.GROWING && s.getProduce() != Produce.WEEDS && s.getStage() < stages)
{
harvestStages.computeIfAbsent(s.getProduce(), k -> new boolean[s.getProduce().getStages()])[s.getStage()] = true;
}
@@ -69,7 +74,7 @@ public class PatchImplementationTest
// Alot of time the final stage is not hit, because some plants do not have a "Check-health" stage
for (int i = 0; i < states.length - 1; i++)
{
Assert.assertTrue(produce.getKey().getName() + " stage " + i + " never found by varbit", states[i]);
collector.checkThat(produce.getKey().getName() + " stage " + i + " never found by varbit", states[i], is(true));
}
}
}