Unit Testing a Website

前端 未结 7 1109
不知归路
不知归路 2021-01-30 09:11

I\'m curious to see how other developers go about testing their web sites. PHP specifically in my case, but this probably spans multiple languages. I\'ve been working on a site

相关标签:
7条回答
  • 2021-01-30 09:37

    One of the best ideas I've heard of, as far as testing web apps go, was to create a script that would go over all the pages in the site and check them for differences from the previous scan, letting you accept changes and fix regressions.

    Generally speaking, automatic testing of GUI applications (websites are GUI apps) is difficult and usually unnecessary. Unit tests work best with simple libraries.

    0 讨论(0)
  • 2021-01-30 09:43

    You might want to check out PHPUnit http://www.phpunit.de/manual/current/en/

    I have started using it on my PHP projects and it's very easy to work with and very powerful. In particular, learn and use mocks: http://www.phpunit.de/manual/3.0/en/mock-objects.html

    Mocking is especially important when unit testing applications that do database operations.

    0 讨论(0)
  • 2021-01-30 09:43

    Take a look at TOAST. It's build specially for CodeIgniter. It uses CI infrastructure, so you can run all test tests via a browser and results are displayed back as a web page (HTML). It's very simple to use.

    I suggest you test your Controllers as well. Testing model is ok, but model is just the DB storage. Controllers contain all the "business logic" and are the place where most things go wrong.

    0 讨论(0)
  • 2021-01-30 09:46

    Have you tried Fitnesse ?

    It helps on creating Acceptance tests. They are specially useful for websites, which doing this kind of tests are a pain.

    There are a couple of videos from unclebob inside the webpage too. The good thing is that Fitnesse is not restricted for website testing, so your knowledge about using it can be used with other apps too.

    The project I'm working on is a Desktop APP written in c++ that uses Fitnesse tests.

    But if you meant unit testing the models (which I think you didn't), they can be create using the phpunit lib. I think the ZEND framework has a similar lib for that.

    0 讨论(0)
  • 2021-01-30 09:49

    For actual unit testing without testing the UI, you should just test the functions in the model. Most of your functionality should be in there anyways.

    You might want to have a look at Selenium for testing the UI of your site. It can record your actions and play them back, or you can edit the scripting directly.
    (source: seleniumhq.org)

    0 讨论(0)
  • 2021-01-30 09:52

    I use Canoo WebTest. It is the best free web site unit test framework out there. It is entirely scriptable with XML and requires no browser so it can run from a build server.

    0 讨论(0)
提交回复
热议问题