Seite 1 von 1

SerializationMock

Verfasst: 21. Nov 2016 14:17
von android_TUD
Hi all,
I have been testing all tests, but eclipse and sbt have been detecting some error in 3 test files: MemoryAndTimeTest, PastComparisonTest, TimeEvaluationTest

-Description Resource Path Location Type
method serialize overrides nothing. Note: the super classes of trait MockTestSerializer contain the following, non final members named serialize: def serialize(name: String,value: Long,unit: String): Unit MemoryAndTimeTest.scala /ex02/src/test/scala/ex02 line 11 Scala Problem
-Description Resource Path Location Type
overriding method deserialize in trait Serializer of type (name: String)List[(java.util.Date, Long, String)]; method deserialize has incompatible type MemoryAndTimeTest.scala /ex02/src/test/scala/ex02 line 15 Scala Problem
etc.
Can anyone help me?
Thank you in advance
Tud

Re: SerializationMock

Verfasst: 21. Nov 2016 14:21
von ManuelWeiel
On a first look, I would say, that you changed the signatures of serialize and deserialize in the Serializer trait, which you should avoid.

Re: SerializationMock

Verfasst: 21. Nov 2016 14:31
von android_TUD
Hi ManuelWeiel,
i think that i don't change anything of the signatures of serialize and deserialize in the Serializer trait. For all traits in PerfSpec.scala i can override and implement these two methods.

Re: SerializationMock

Verfasst: 21. Nov 2016 14:37
von ManuelWeiel
Please DM me your implementation of your trait Serializer.

Re: SerializationMock

Verfasst: 21. Nov 2016 15:14
von ManuelWeiel
Looking at your current implementation, the issue is really the type signature of the serialize and deserialize methods.

In your case the problem is more subtle though. You import

Code: Alles auswählen

import java.lang.Long
. Without importing this, will default to the Scala version of a long. By using your import, you force to use the Java version of long.
As the tests use the Scala version in the signatures and your PerSpec.scala uses the Java version, the type signatures do not match.

I'd advise to stick with the Scala version of Long.

Hint: to Parse a long from and String you can use the method toLong.

Re: SerializationMock

Verfasst: 21. Nov 2016 15:27
von android_TUD
Oh, this is my mistake.I should remember this point. Many thanks for your help :)