CodeIgniter 2.1 和 SimpleTest - 进行简单测试

发布于 2024-12-23 09:32:53 字数 1651 浏览 1 评论 0原文

我目前使用 CI 2.1 和 Netbeans 7.0 作为我的投资 IDE。我想使用 SimpleTest 创建一些简单的单元测试。特别是 Eric Barnes 使用的方法和他在 Git Hub CodeIgniter-SimpleTest 上找到的代码。 (https://github.com/ericbarnes/codeigniter-simpletest

我创建了一个新的 CI我使用 Netbeans 7.0 编写了一个应用程序,并连接到我的数据库(其中包含 1 个名为 schools 的表,其中包含典型的 schema schoolid、schoolname、schooladdress 等)。我创建了一个控制器 (simpleapp),它加载一个名为 schools_model 的模型。 school_model 使用名为 getAll() 的方法获取所有学校。另一种方法称为 getSchoolName(id),接受学校 ID 并返回学校名称。

然后控制器加载一个名为 schools_view 的视图来显示所有学校。 时,它会显示所有学校

非常简单的东西............并且它工作完美,当我将浏览器指向http ://localhost/SimpleTest/simpleapp/getAllSchools

(我也使用 .htaccess 文件,因此没有 index.php)

我的问题是......

我如何让 SimpleTest 使用Eric 提供的 Git hub 代码?

我遵循了 Eric 的设置建议,但不知道要指向哪个 URL 来创建他提供的屏幕转储。我维护了埃里克建议的目录结构,但没有取得任何成功。 Eric 建议将浏览器指向 yoursite.com/unit_test.php,但我得到了 localhost/SimpleTest/unit_test.php 的 404 页面未找到错误

我认为上述错误是由于这样的事实,就像大多数 CI 应用程序一样,我们需要首先使用控制器。

我将不胜感激该领域的任何指示。


我已经完全按照你的建议做了。我已将 unit_test.php 文件放置在根目录中,并按照建议设置测试目录结构。但是,当我指向 localhost/SimpleTest/unit_test.php 时,我收到 404 错误。

我的目录结构看起来像

源文件

-application (folder)
-system(folder)
-tests(folder from git hub with model/test_schools_model.php)
-.htaccess
-index.php
-licence.txt
-unit_test.php

这是 .htaccess 问题导致我无法查看 localhost/SimpleTest/unit_test.php 的原因吗?

I am currently using CI 2.1 and Netbeans 7.0 as my inveiglement IDE. I would like to create some simple unit testing using SimpleTest. In particular the methodology used by Eric Barnes and his code found at Git Hub CodeIgniter-SimpleTest. (https://github.com/ericbarnes/codeigniter-simpletest)

I have created a new CI application using Netbeans 7.0 and connected to my database (which contains 1 table called schools with the typical schema schoolid, schoolname, schooladdress etc.). I have created a controller (simpleapp), which loads a model called schools_model. The schools_model gets all the schools using a method called getAll(). Another method called getSchoolName(id), accepts a school ID and returns the school name.

The controller then loads a view called schools_view to display all the schools. Pretty simple stuff…....... and it works flawlessly, displaying all the schools when I point my browser to

http://localhost/SimpleTest/simpleapp/getAllSchools

(I am also using a .htaccess file, hence no index.php)

My question is this….......

How do I get SimpleTest to work using the Git hub code supplied by Eric?

I have followed Eric’s set-up advise, but don’t know what URL to point to to create the screen dumps he provides. I have maintained the directory structure Eric suggests but haven’t had any success. Eric suggest to point the browser to yoursite.com/unit_test.php, but I get a
404 page not found error for localhost/SimpleTest/unit_test.php

I assume the above error is due to the fact, like most CI applications, we need to use a controller first.

I would appreciate any direction in this area.


I have done exactly what you suggested. I have placed the unit_test.php file in the root directory and set up the test directory structure as suggested. However, when I point to localhost/SimpleTest/unit_test.php I get the 404 error.

My directory structure looks like

Source Files

-application (folder)
-system(folder)
-tests(folder from git hub with model/test_schools_model.php)
-.htaccess
-index.php
-licence.txt
-unit_test.php

Is it a .htaccess issue the reason I cannot view localhost/SimpleTest/unit_test.php?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉生梦死 2024-12-30 09:32:53

你是对的,你需要去 yoursite.com/unit_test.php 或者在你的情况下 localhost/SimpleTest/unit_test.php

你需要将 unit_test.php 文件从 github 复制到站点根目录中,并将测试目录也放在那里。然后将测试放入测试/下的适当文件夹中

You are correct you need to go to yoursite.com/unit_test.php or in your case localhost/SimpleTest/unit_test.php

You need to copy the unit_test.php file from github into the sites root directory and place the tests directory there too. You then put your tests in the appropriate folder under tests/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文