ksylva / PDL_2020-2021_GR6

Wikipedia Matrix
0 stars 0 forks source link

TestParserWikiText : testParseWikiTextNbCell4 failed #6

Open ksylva opened 3 years ago

ksylva commented 3 years ago

java.lang.AssertionError: We should have 114 cells expected:<114> but was:<0> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotEquals(Assert.java:834) at org.junit.Assert.assertEquals(Assert.java:645) at testsProjet.TestParserWikiText.testParseWikiTextNbCell4(TestParserWikiText.java:292) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

bene18 commented 3 years ago

he test method "testParseWikiTextNbCell4" works well. The problem lies in the URL passed as a parameter to the parser. Here is the url used in the method in question: https://en.wikipedia.org/w/index.php?title=Comparison_of_DEX_software&action=edit

If you open this url in your browser, you may notice that it does not contain wikitext code:

The table extraction algorithm via wikitext (see the ParserWikiText.java class) relies on the wikitext code to identify the tables in the page, so it is normal that it finds 0 cells on this page since it does not contain any wikitext code.

To fix this problem, you just have to use in the test method (testParseWikiTextNbCell4) a url containing wikitext code. Example: https://fr.wikipedia.org/w/index.php?title=Facebook This page contains a table of 165 cells and is also coded in wikitext. It can be used to run the test method "testParseWikiTextNbCell4" by adapting the code as follows:

replace the line urlWikiText = "https://en.wikipedia.org/w/index.php?title=Comparison_of_DEX_software&action=edit; with urlWikiText="https://fr.wikipedia.org/w/index.php?title=Facebook&action=edit"; and assertEquals("We should have 114 cells ", 114, nbCell); by assertEquals("We should have 165 cells", 165, nbCell);

in the test method "testParseWikiTextCell4";

Note: You will agree with me that the names of the test methods are not very meaningful (see explanation below):

testParseWikiTextNbCell4==> to test the calculation of the number of cells in a table.

Whether it's 4 or 5, the test method of cell count calculation keeps the same principle which is to check that the cell count calculation still works. So there is not much point in doing a "testParseWikiTextNbCell4" and "testParseWikiTextNbCell5" test method since both play the same role.

We can discuss this in another issue to find more relevant names.