Error java.lang.RuntimeException: Stub! in Android with Fitnesse testing

前端 未结 4 1492
Happy的楠姐
Happy的楠姐 2020-11-28 14:03

I\'m trying to create a test fixture using Fitnesse framework, and I want to test a function which retrieves data from a server (RESTFUL service). My test case

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-28 14:41

    You can fix this problem and test within your IDE really easily by using Roboelectric.

    As dtmilano said, you can't run Android code on your laptop as is, but Roboelectric basically substitutes the actual method implementations for the stubs in Android.jar.

    Two things to watch out for if you go with this solution:

    • Make sure that your JAR import is above the Android JAR in your dependencies list if using IntelliJ

    • It defaults to blocking HTTP requests under the assumption that you don't actually want to change the state of a server somewhere. You can, however, disable this quite easily: Roboelectric.getFakeHttpLayer().interceptHttpRequests(false);

提交回复
热议问题