modified tests, improved configuration, introduced aspect #1714

Merged
merged 4 commits into from Dec 31, 2013

Conversation

Projects
None yet
4 participants
@Ragazzo
Contributor

Ragazzo commented Dec 30, 2013

I improved current testing support by adding AspectMock and Specify. What benefits we get:

  1. AspectMock allows us to mock directly to the class. Great ability. Can be compared to mockery but it uses class aliases and can cause fatal error when same name class will be included.
  2. Specify syntax sugar that adds good readability. Also it is a best practice to structure in blocks your assertions, so they will be easy to read and understand.

This two repos are maintained by @DavertMik so we will get support from him i think. Also you can review and see by yourself that tests are easy to use/read/understand.

I made some _bootstrap.php modifications because of AspectMock should be initialized before Yii, and load it internally.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 30, 2013

Contributor

@qiangxue i do really think that this changes should be implemented because of they are very useful for developers especially who are starting to learn TDD for example.

Contributor

Ragazzo commented Dec 30, 2013

@qiangxue i do really think that this changes should be implemented because of they are very useful for developers especially who are starting to learn TDD for example.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 30, 2013

Contributor

Related with this issue #1709 and this one #1694 as example of how it can help developer to mock things.

Contributor

Ragazzo commented Dec 30, 2013

Related with this issue #1709 and this one #1694 as example of how it can help developer to mock things.

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Dec 30, 2013

Member

AspectMock should be initialized before Yii, and load it internally.

Why?

Member

qiangxue commented Dec 30, 2013

AspectMock should be initialized before Yii, and load it internally.

Why?

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 30, 2013

Contributor

It is Go! AOP framework (created by @lisachenko) limitation, generally it is because of how AOP work. Some links:

Contributor

Ragazzo commented Dec 30, 2013

It is Go! AOP framework (created by @lisachenko) limitation, generally it is because of how AOP work. Some links:

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 30, 2013

Contributor

I think we also can wait @DavertMik as a creator of AspectMock for bringing up some internal knowledges.

Contributor

Ragazzo commented Dec 30, 2013

I think we also can wait @DavertMik as a creator of AspectMock for bringing up some internal knowledges.

@DavertMik

This comment has been minimized.

Show comment
Hide comment
@DavertMik

DavertMik Dec 31, 2013

Contributor

I'd rather leave AspectMock aside. Sure it is really effective tool especially for unit testing in Yii and the only option in such cases as form testing here goes a link to my post on that.

But I'd rather not introduce this into Yii2 core. Just because it is still is (and looks like ever be) experimental framework which does a black magic. It will work for most of cases, but we can't provide a support in cases when it doesn't work, works in improper way, or even worst - affects the application in production.

AspectMock will be developed and supported. It's a really useful tool. But I'm not sure it may fit to everyone,


Even though I can recommend specify as it makes tests more descriptive and readable. They are simple and sweet and can bring much better structure into classical unit tests.

Contributor

DavertMik commented Dec 31, 2013

I'd rather leave AspectMock aside. Sure it is really effective tool especially for unit testing in Yii and the only option in such cases as form testing here goes a link to my post on that.

But I'd rather not introduce this into Yii2 core. Just because it is still is (and looks like ever be) experimental framework which does a black magic. It will work for most of cases, but we can't provide a support in cases when it doesn't work, works in improper way, or even worst - affects the application in production.

AspectMock will be developed and supported. It's a really useful tool. But I'm not sure it may fit to everyone,


Even though I can recommend specify as it makes tests more descriptive and readable. They are simple and sweet and can bring much better structure into classical unit tests.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 31, 2013

Contributor

Ok, then will make changes and exclude AspectMock from current PR. Will mention it in docs guide for testing.

Contributor

Ragazzo commented Dec 31, 2013

Ok, then will make changes and exclude AspectMock from current PR. Will mention it in docs guide for testing.

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 31, 2013

Contributor

@qiangxue i think we should raise method visibility LoginForm::getUser to public (for testing purposes too) :)

Contributor

Ragazzo commented Dec 31, 2013

@qiangxue i think we should raise method visibility LoginForm::getUser to public (for testing purposes too) :)

@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Dec 31, 2013

Member

Feel free to do so if needed.

Member

qiangxue commented Dec 31, 2013

Feel free to do so if needed.

@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko Dec 31, 2013

I agree with @DavertMik that AspectMock is not very stable yet, because of techniques that are used in Go! AOP framework. However, AspectMock is very promising and interesting project, but it requires more attention and testing to be stable and predictable in all cases. So, it will be better to switch to standard testing framework to be sure that everything will be ok.

BTW, Yii framework can be integrated will go-aop to use an aspect-oriented programming. I have a post about this: http://go.aopphp.com/blog/2013/09/28/aspect-oriented-programming-with-yii/

I agree with @DavertMik that AspectMock is not very stable yet, because of techniques that are used in Go! AOP framework. However, AspectMock is very promising and interesting project, but it requires more attention and testing to be stable and predictable in all cases. So, it will be better to switch to standard testing framework to be sure that everything will be ok.

BTW, Yii framework can be integrated will go-aop to use an aspect-oriented programming. I have a post about this: http://go.aopphp.com/blog/2013/09/28/aspect-oriented-programming-with-yii/

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 31, 2013

Contributor

Reverted aspect-mock changes. Done, ready for review.

Contributor

Ragazzo commented Dec 31, 2013

Reverted aspect-mock changes. Done, ready for review.

qiangxue added a commit that referenced this pull request Dec 31, 2013

Merge pull request #1714 from Ragazzo/tests_improved
modified tests, improved configuration, introduced aspect

@qiangxue qiangxue merged commit 53daaf8 into yiisoft:master Dec 31, 2013

1 check was pending

default The Travis CI build is in progress
Details
@qiangxue

This comment has been minimized.

Show comment
Hide comment
@qiangxue

qiangxue Dec 31, 2013

Member

Cool! Thanks!

Member

qiangxue commented Dec 31, 2013

Cool! Thanks!

@Ragazzo Ragazzo deleted the Ragazzo:tests_improved branch Dec 31, 2013

@Ragazzo

This comment has been minimized.

Show comment
Hide comment
@Ragazzo

Ragazzo Dec 31, 2013

Contributor

Great :) Still need to improve db support)

Contributor

Ragazzo commented Dec 31, 2013

Great :) Still need to improve db support)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment