预期使用内置于CodeIgniter的单元测试

时间:2022-10-06 19:16:22

In most framework unit testing implementations, you have a set of a tests and you execute those tests from a single [console] command. The tests run and a result is given. That result varies but generally it includes pass / fail.

在大多数框架单元测试实现中,您有一组测试,并且您可以从单个[console]命令执行这些测试。测试运行并给出结果。结果有所不同,但通常包括通过/失败。

CodeIgniter’s unit testing framework appears different and I have noticed an extensive collection of random tack-on-projects to either enhance or replace the CodeIgniter unit testing framework.

CodeIgniter的单元测试框架看起来不同,我注意到了大量的随机附加项目,以增强或替换CodeIgniter单元测试框架。

My question is this: What is the intended work flow or use of the unit testing framework built in to CodeIgniter?

我的问题是:CodeIgniter内置的单元测试框架的工作流程或用途是什么?

I read the documentation; I get it. It’s a simple class. But where does one utilize the class?

我看了文件;我知道了。这是一个简单的课程。但是哪个人利用这个课程呢?

For example, do all the tests go in to a single “test” controller? Or do the tests get intermingled in to each controller? Then there is the question of the models and custom helpers... Also, I'm assuming tests are run via a browser (or the alike) request...

例如,所有测试都进入一个“测试”控制器吗?或者测试是否混合到每个控制器?然后是模型和自定义助手的问题......而且,我假设测试是通过浏览器(或类似的)请求运行的...

Thanks for the guidance!

谢谢你的指导!

Regards,
Frank

问候,弗兰克

1 个解决方案

#1


4  

I've received an answer from another source and I want to post it here since I am aware of it.

我收到了另一个来源的答案,我想在此发布,因为我知道它。

The basic answer is that the CI (CodeIgniter) unit test class is not intended like a traditional unit test suite (JUnit, NUnit, or python's unittest). In CI, the class is intended to be used within the target (the testing target's code base).

基本答案是CI(CodeIgniter)单元测试类不像传统的单元测试套件(JUnit,NUnit或python的unittest)。在CI中,该类旨在用于目标(测试目标的代码库)中。

To be clear: I'm not endorsing this nor am I sure this is the intended use of the CI unit_test class. This is just what I was told thus far. Perhaps others heard this too and can vote it up. If this is voted up or has support via comments, I'll mark this as an answer. I am still interested in differing opinions.

要明确:我不赞同这一点,也不确定这是CI unit_test类的预期用途。这就是我到目前为止所说的。也许其他人也听过这个并且可以投票。如果这是通过投票或通过评论获得支持,我会将此标记为答案。我仍然对不同意见感兴趣。

#1


4  

I've received an answer from another source and I want to post it here since I am aware of it.

我收到了另一个来源的答案,我想在此发布,因为我知道它。

The basic answer is that the CI (CodeIgniter) unit test class is not intended like a traditional unit test suite (JUnit, NUnit, or python's unittest). In CI, the class is intended to be used within the target (the testing target's code base).

基本答案是CI(CodeIgniter)单元测试类不像传统的单元测试套件(JUnit,NUnit或python的unittest)。在CI中,该类旨在用于目标(测试目标的代码库)中。

To be clear: I'm not endorsing this nor am I sure this is the intended use of the CI unit_test class. This is just what I was told thus far. Perhaps others heard this too and can vote it up. If this is voted up or has support via comments, I'll mark this as an answer. I am still interested in differing opinions.

要明确:我不赞同这一点,也不确定这是CI unit_test类的预期用途。这就是我到目前为止所说的。也许其他人也听过这个并且可以投票。如果这是通过投票或通过评论获得支持,我会将此标记为答案。我仍然对不同意见感兴趣。