DESCRIPTION

tmf: Add unit tests to pcap

Change-Id: I6cb472acb44a6108242188dd24ae5b3386388c62
Signed-off-by: Itzel Singleton xxx@xxx.xxx


COMMENTS

author: Itzel Singleton
date: 2014-07-21 18:47:50.000000000

Patch Set 6: Commit message was updated

-------------------------------------
author: Brenden Conley
date: 2014-07-21 18:47:56.000000000

Patch Set 6:

Build Started https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/7851/

-------------------------------------
author: Brenden Conley
date: 2014-07-21 19:25:27.000000000

Patch Set 6: Verified+1

Build Successful 

https://hudson.eclipse.org/linuxtools/job/linuxtools-gerrit/7851/ : SUCCESS

-------------------------------------
author: Braxton Mccarthy
date: 2014-07-21 22:17:56.000000000

Patch Set 6:

(29 comments)

First part

Line:25, lttng/org.eclipse.linuxtools.pcap.core.tests/shared/org/eclipse/linuxtools/pcap/core/tests/shared/PcapTestTrace.java -> add empty line after

Line:50, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileReadTest.java -> same line

Line:13, lttng/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java -> remove

Line:34, lttng/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapSeekBenchmark.java -> put inside the class javadoc

Line:25, lttng/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllTests.java -> alphabetical order

Line:46, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java xxx@xxx.xxx on same line

Line:52, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java -> same line

Line:65, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileEndiannessTest.java -> you can let the test methods throw exceptions, if they happen, JUnit will have the reference to it, making it a bit easier to debug.

Line:45, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/PacketTest.java -> use a 

 xxx@xxx.xxx
  public static void setUpClass() {
    ...
  }

instead

Line:47, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java -> same line

Line:79, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenTest.java -> same line

Line:28, lttng/org.eclipse.linuxtools.pcap.core.tests/META-INF/MANIFEST.MF -> Do you really use Antlr in there?

Line:13, lttng/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java -> no need to mention it ;)

Line:32, lttng/org.eclipse.linuxtools.pcap.core.tests/perf/org/eclipse/linuxtools/pcap/core/tests/perf/trace/PcapReadBenchmark.java -> put this inside the class's Javadoc, so we have slightly more chance of seeing it.

Line:11, lttng/org.eclipse.linuxtools.pcap.core.tests/rsc/get-traces.xml -> from the Wireshark website and available (no s)

Line:40, lttng/org.eclipse.linuxtools.pcap.core.tests/pom.xml -> Perhaps check if the property "maven.test.skip" is set, and if so skip downloading the trace.

We should do this in ctf.core.tests too...

Line:39, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java -> doesn't matter much, but in test methods you can use @Before xxx@xxx.xxx for static things) instead of constructors and initializers. For stuff that prepares the "fixture" on which the test will be run, it's better practice to use those.

Line:72, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java -> saaaame liiiiine

by the way, I just realized, why not just make you xxx@xxx.xxx ?

Line:80, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/packet/BadPacketTest.java -> the proper way to do this is to mark the method with:

 xxx@xxx.xxx
  public void PacketExceptionTest() throws BadPacketException, ...

this will fail the test if the expected exception is not received, and vice versa.

Line:61, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/AllPcapCoreTests.java -> Gotta admit this is cute, but you should follow the same format as the other test packages. Which is having separate AllTest.java files in each package, and have the master suite here just link to everyone one of those. It scales much better.

Line:47, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> same line

Line:52, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> leave these exception in the method signature. it will unbloat this code a bunch!

Line:56, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> you should have a separate test methods for this.

Line:62, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> same line

Line:71, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> separate test method

Line:77, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/file/PcapFileOpenFailTest.java -> same line

Line:24, lttng/org.eclipse.linuxtools.lttng.alltests/src/org/eclipse/linuxtools/lttng/alltests/RunAllPerfTests.java -> alphabetical order plz

Line:15, lttng/org.eclipse.linuxtools.pcap.core.tests/build.properties -> here too, put perf/ before shared/ (don't think it really matters much here tho)

Line:7, lttng/org.eclipse.linuxtools.pcap.core.tests/.classpath -> Put perf/ above shared/. They show up in that order when you load it in Eclipse, so makes more sense to have shared/ at the end.

-------------------------------------
author: Braxton Mccarthy
date: 2014-07-21 22:32:58.000000000

Patch Set 6:

(9 comments)

and second part

Very good work! It's not always fun to write tests, but it's very useful in the long term!

The tests themselves look good, mostly some comments about "how" to write tests rather that "what" to test. For instance, many of your test methods are a bit long, you could make use of private "fixture" fields, @Before/@After methods, and smaller but xxx@xxx.xxx methods.

Line:32, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java -> Yeah it's fine. A test class should test a "concept". If one concept has a class and a factory, then it's ok to have one test for both.

Line:81, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/stream/StreamBuildTest.java -> might be clearer to do
  for (1 to 42)  {
    .add()
  }
  .remove(17)
  .remove(23)

Line:46, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java xxx@xxx.xxx instead

Line:153, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ipv4/IPv4PacketTest.java -> don't need to return, fail() will stop it

Line:31, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ProtocolTest.java -> hmm, this doesn't seem extremely useful.. you're just returning statically-defined values, right?

Meh, doesn't hurt I guess, it'll pad the test coverage %  ;)

Line:47, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java xxx@xxx.xxx

Line:79, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/ethernet2/EthernetIIPacketTest.java -> I think there is a constructor ImmutableMap.of(K, V, K, V,...) that goes for up to 5 entries.

Line:185, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java -> no need fo return

Line:210, lttng/org.eclipse.linuxtools.pcap.core.tests/src/org/eclipse/linuxtools/pcap/core/tests/protocol/pcap/PcapPacketTest.java -> no need

-------------------------------------
