-3

I have a class that implements serializable and I need it to be there.

public class Alpha implements Beta {
}

Is there a way to check that it is implementing Beta via a unit test?

leonardkraemer
  • 6,573
  • 1
  • 31
  • 54
Moses Liao GZ
  • 1,556
  • 5
  • 20
  • 45

1 Answers1

1

The easiest way to test a class is just to require that type as a parameter:

public void someMethod( Beta b ) {
  // ...
}

For Serializable, just use that type.

public void otherMethod( Serializable ser ) {

If you need a class that implements two types, then you should make an interface that expresses that type.

public interface MyType extends Beta, Serializable {}

Then just use MyType wherever you need both types.

markspace
  • 10,621
  • 3
  • 25
  • 39