Can't run JUnit 4 test case in Eclipse Android project

后端 未结 2 1862
难免孤独
难免孤独 2020-11-28 05:22

I am new to Java and am trying to run a unit test on a class I am writing. Eclipse (3.5) created the unit test class for me and added Junit4 to my class path.

My Cla

2条回答
  •  佛祖请我去吃肉
    2020-11-28 06:21

    Since Alex Spurling's instructions are no longer valid for Eclipse Juno and the latest Android SDK, it may be useful to give another alternative:

    1. Create a separate ordinary Java library project that houses all the code that does not have dependencies to the Android platform.
    2. Write JUnit tests normally.
    3. Include that project to your Android project as a library reference.
    4. Use SLF4J or other high level library for logging.

    It's a bit of a hassle on small projects, but OTOH it helps to enforce modularity and interface segregation.

提交回复
热议问题