Increase unit test coverage in package "core"#50
Conversation
There was a problem hiding this comment.
Feedback regarding tests:
- Please remove the "test" prefix from method names, since in the past @thomasgrassauer and I agreed to leave this out. Reason - The classes themselves already do contain the Test word in them and therefore this info is redundant.
Other than that there are several minor comments which are only intended as information about some shortcut methods.
|
|
||
| // create a valid session | ||
| final Session session = openKit.createSession("127.0.0.1"); | ||
| assertThat(session, not(nullValue())); |
There was a problem hiding this comment.
org.hamcrest.Matchers.notNullValue -> mean it can be used like
assertThat(session, notNullValue());|
|
||
| // User has forgotten to initialize => shall not throw an exception | ||
| final Session session = openKit.createSession("127.0.0.1"); | ||
| assertThat(session, not(nullValue())); |
There was a problem hiding this comment.
assertThat(session, notNullValue());| final SessionImpl session2impl = (SessionImpl)session2; | ||
|
|
||
| // verify that the two sessions exist and are not the same | ||
| assertThat(session1impl, not(session2impl)); |
There was a problem hiding this comment.
I guess it would make sense to test for
assertThat(session1impl, not(sameInstance(session2impl)));This makes clear, that both variables shall not be the same instance.
| assertThat(session1impl, not(session2impl)); | ||
| } | ||
|
|
||
| private Configuration createTestConfig() { |
There was a problem hiding this comment.
I guess this could be a setUp method
|
|
||
| // child leaves immediately | ||
| final Action retAction = childAction.leaveAction(); | ||
| assertThat(retAction, is(equalTo((Action) rootAction))); |
There was a problem hiding this comment.
assertThat(retAction, is(sameInstance(rootAction)));|
|
||
| // test the constructor call | ||
| final WebRequestTracerURLConnection conn = new WebRequestTracerURLConnection(beacon, action, urlConnection); | ||
| assertThat(conn, not(nullValue())); |
There was a problem hiding this comment.
assertThat(conn, notNullValue());|
|
||
| // verify that the tag is now set | ||
| existingTag = urlConnection.getRequestProperty(OpenKitConstants.WEBREQUEST_TAG_HEADER); | ||
| assertThat(existingTag, not(nullValue())); |
There was a problem hiding this comment.
assertThat(existingTag, notNullValue());| assertThat(session.isEmpty(), is(true)); | ||
| } | ||
|
|
||
| private Beacon createTestBeacon() { |
There was a problem hiding this comment.
method can be made static
|
|
||
| // verify the correct methods being called | ||
| verify(beaconSender, times(1)).startSession(eq(session)); | ||
| verify(beacon, times(1)).reportCrash(eq(errorName), eq(reason), eq(stacktrace)); |
There was a problem hiding this comment.
small info: AFAIK the eq() are not necessary in this case
| retAction = rootAction.leaveAction(); | ||
| assertThat(retAction, is(nullValue())); | ||
|
|
||
| // verify that beacon cache is now empty |
There was a problem hiding this comment.
// verify that open child actions are now empty…e-1.3.3 to release/1.3 * commit '9223f63d72824a5a05a05b6cb41eb3777c7171a9': Prepare to release version 1.3.3 GitOrigin-RevId: 776b7a33897fb3bd6e7fc68cb63ef5cce65876b1
No description provided.