Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Table formatter does not work with a List that is empty #341

Closed
nikowitt opened this issue Mar 23, 2018 · 3 comments
Closed

@Table formatter does not work with a List that is empty #341

nikowitt opened this issue Mar 23, 2018 · 3 comments
Milestone

Comments

@nikowitt
Copy link
Contributor

Hi,

@Test
public void emptyJGivenTable() {
	given().create_table(Collections.emptyList());
}

static class TestStage extends Stage<TestStage>  {

	public TestStage create_table(@Table List l) {
		return self();
	}
}

results in an exception:


java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

	at java.util.ArrayList.rangeCheck(ArrayList.java:657)
	at java.util.ArrayList.get(ArrayList.java:433)
	at com.tngtech.jgiven.report.text.PlainTextTableWriter.getColumnSpecs(PlainTextTableWriter.java:114)
	at com.tngtech.jgiven.report.text.PlainTextTableWriter.writeDataTable(PlainTextTableWriter.java:31)
	at com.tngtech.jgiven.report.text.PlainTextScenarioWriter.printDataTable(PlainTextScenarioWriter.java:178)
	at com.tngtech.jgiven.report.text.PlainTextScenarioWriter.printStep(PlainTextScenarioWriter.java:139)
	at com.tngtech.jgiven.report.text.PlainTextScenarioWriter.visit(PlainTextScenarioWriter.java:93)
	at com.tngtech.jgiven.report.model.StepModel.accept(StepModel.java:77)
	at com.tngtech.jgiven.report.model.ScenarioCaseModel.accept(ScenarioCaseModel.java:73)
	at com.tngtech.jgiven.report.model.ScenarioModel.accept(ScenarioModel.java:28)
	at com.tngtech.jgiven.report.text.PlainTextReporter.visit(PlainTextReporter.java:68)
	at com.tngtech.jgiven.report.model.ScenarioModel.accept(ScenarioModel.java:26)
	at com.tngtech.jgiven.report.model.ReportModel.accept(ReportModel.java:45)
	at com.tngtech.jgiven.report.text.PlainTextReporter.write(PlainTextReporter.java:51)
	at com.tngtech.jgiven.report.impl.CommonReportHelper.finishReport(CommonReportHelper.java:30)
	at com.tngtech.jgiven.junit.JGivenClassRule.finished(JGivenClassRule.java:22)
	at org.junit.rules.TestWatcher.finishedQuietly(TestWatcher.java:117)
	at org.junit.rules.TestWatcher.access$400(TestWatcher.java:46)
	at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:64)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

Using additional attributes on @table might cause different exceptions, but I assume the root cause is the same.

Best regards,
Niko

@janschaefer janschaefer added this to the v0.16.1 milestone Jul 6, 2018
@janschaefer
Copy link
Contributor

Thanks for the report!

@janschaefer
Copy link
Contributor

What would be your expected behavior? Should the report contain nothing or should a more meaningful exception be thrown?

@janschaefer
Copy link
Contributor

I fixed it now to just show nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants