dounai6613 2011-05-08 10:58
浏览 50
已采纳

使用PHPUnit测试Facebook应用程序

I am building a Facebook application with PHP and I would like to implement PHPUnit tests. The problem is, I think, with the Facebook authorization and getting the dynamic token. During testing the token cannot be received and my tests fail.

I read that this problem can be avoided using "mock objects" but my app is relying on the social graph and therefore this idea does not seem like a good option.

So I hope that someone could explain me how this can be done or point me to some other approach for automated Facebook apps testing.

Have a nice day :)

  • 写回答

3条回答 默认 最新

  • dongyongyu0789 2011-05-09 16:48
    关注

    I read that this problem can be avoided using "mock objects" but my app is relying on the social graph and therefore this idea does not seem like a good option.

    One question I would ask here is how do you expect to deterministically (and quickly!) test your application based on different structures of the social graph? I would recommend doing the legwork to create an internal representation of the social graph in your application so your business logic will work against that representation instead of talking directly to FB. Then you would have a separate component that would generate this internal representation of the graph via the Facebook APIs.

    Your tests could then construct any graph of their choosing using your internal representation and Facebook is now totally out of the picture for you to accomplish your original goal to verify your app's logic.

    If you don't want to do this legwork, the value of writing automated tests against the live system is limited as it will be difficult to investigate test failures and tests of these nature tend to be very brittle (i.e. they can fail because of configuration errors, network errors, etc)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求