Welcome Guest, Not a member yet? Register   Sign In
SimpleTester 1.0 - CI-library for unit testing
#11

[eluser]Unknown[/eluser]
Could you post an example of how I might test a Controller method with Simpletester?

Cheers,

Chris
#12

[eluser]ciscoheat[/eluser]
A controller method is not the best thing to test, since it handles redirection, user input and other high-level actions. Unit testing is much better suited for testing the integrity of libraries and plugins (models to some extent), so if you want an example of how to do that, let me know!

For testing the actual web user interaction, check out Selenium, http://selenium.openqa.org/
#13

[eluser]Unknown[/eluser]
[quote author="ciscoheat" date="1198473823"]
5. Add “simpletester” to autoloading libraries in config/autoload.php
[/quote]

with this i got "Unable to load the requested class: simpletester"

but if i change 'simpletester' to 'SimpleTester' i got
Code:
A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for SimpleTester::__construct(), called in /home/jarod/testapp/system/libraries/Loader.php on line 871 and defined

Filename: libraries/SimpleTester.php

Line Number: 35
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: params

Filename: libraries/SimpleTester.php

Line Number: 45
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: params

Filename: libraries/SimpleTester.php

Line Number: 46
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: params

Filename: libraries/SimpleTester.php

Line Number: 47

i'm using
CI 1.6.1
SimpleTest 1.0.1 beta2
#14

[eluser]wmbetts[/eluser]
I just had the same problem, but I fixed it!. You need to goto your system/application/config directory and rename SimpleTester.php to simpletester.php all lower case.

William Betts
#15

[eluser]cfraz[/eluser]
cisco:

I tried your SimpleTester and really like it. I set it up and the template tests work perfectly.

One of the reasons I wanted to try the SimpleTest library is its integrated WebTester. I added

Code:
require_once($libraryDir . '/web_tester.php');

to libraries/simpletester.php, hoping that would give me all the WebTester functionality. The WebTester asserts seem to work, but when I try to get a page with
Code:
class TestOfWebPage extends WebTestCase {
    
    function testHomepage() {
        $this->get('http://localhost/webtest/');
    }
}

the server just hangs and eventually I get a Nothing Fetched message. This is on Win2003/IIS 6 (I don't have the option of running Apache here).

When I set up SimpleTest in a non-CI framework, the WebTester works fine. Any ideas what's wrong?
#16

[eluser]philmctim[/eluser]
Just wanted to add my thanks (and a 'gotcha!') to this thread.

I just installed this add-on - took me about 15 mins in total to get the default tests running (and that was the first 15 mins of a Sunday morning - not often that they are productive!)

The gotcha I hit was adding 'simpletest' to the autoload list - it needs to be 'simpletester'. The documentation is correct, I just didn't read it carefully enough.

Thanks again.
#17

[eluser]philmctim[/eluser]
OK, so now I have a question...

What if I didn't want the unit tests to run every time I made a call to the server?

Some of my unit tests are quite DB-intensive.

Some of my unit test are only useful when I've just loaded-up my test suite of data that is to be processed.

Just wondering if anyone thinks the same way and what they did about it.

Thanks
#18

[eluser]Unknown[/eluser]
Install was quick and simple, library works just fine, its code is clean and well documented and author responses to emails (and his answers is clear and helpful!)

Thank you, Andreas!

--
Alexey.
#19

[eluser]jalalski[/eluser]
I'm getting the following error whenever a test fails:
Code:
Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in /home/wwwroot/xxxxx/xxxxx/ci/libraries/Exceptions.php on line 160

Successful test work out fine.
#20

[eluser]Natebot[/eluser]
An important tip:
You must set
Code:
$config['compress_output'] = FALSE;
in config/config.php in order for the autoloading simpletester library to directly output to the browser with ob_start.




Theme © iAndrew 2016 - Forum software by © MyBB