SwiftKit / CuckooGenerator

Generator of Mocks for Cuckoo
MIT License
20 stars 4 forks source link

Class Mock Syntax Errors #1

Open JRG-Developer opened 8 years ago

JRG-Developer commented 8 years ago

@TadeasKriz I'm opening this issue per our discussion on Cuckoo repository.

Per the README, CuckooGenerator supports mocks created from classes.

In my testing, however, I cannot get this to work. Rather, there are always several syntax errors.

CuckooTestDummy is a dummy test project that showcases the errors I'm seeing.

TadeasKriz commented 8 years ago

This seems to be a problem with NSObject class or required initializers. I will look into it during the weekend and see if I can find a fix.

JRG-Developer commented 8 years ago

Cool, thanks @TadeasKriz !

If I can figure out the cause, I'll open a PR. ;)

TadeasKriz commented 8 years ago

Thanks!

From what I see, it is the logic of tokenization and generation of initializers. I probably completely forgot about custom initializers as I added class support in a bit of a hurry. Great catch! :)

TadeasKriz commented 8 years ago

Hey, @a-voronov added basic support for initializers, I'll give the dummy project a try :)

TadeasKriz commented 8 years ago

Unfortunately, no dice, it will need more work.

a-voronov commented 8 years ago

@TadeasKriz Thanks! Yep, there are more issues with generating mocks for classes. Protocols though seem to be generated correctly, but need to verify more edge cases.

Cuckoo.StubbingProxy and Cuckoo.VerificationProxy generate generic initializers with func keywords which is incorrect.

TadeasKriz commented 8 years ago

@a-voronov I'm aware of these problems. Fortunately @FilipDolnik is working on tests for the generator, so it will be easier to test more files whether or not the generator works as expected.

bobbelkl commented 8 years ago

Any news on the initializers issue?

wfrank2509 commented 8 years ago

It would be great to be able to Mock classes with custom initializers as this is typically heavily used in our projects or dependent frameworks where we do not have much influence on the structure.

Is there a timeline or any plans for working on this issue? Thanks!

TadeasKriz commented 8 years ago

Hey guys, new Cuckoo 0.7.0 is out with fixed initializers issue :) Sorry for the long wait.

wfrank2509 commented 8 years ago

Great Job. Thank you!

0xPr0xy commented 7 years ago

Hey guys,

I'm having an issue related to initializers, so I thought I could add it to this thread. When generating a mock for a class with a deinit method, I'm receiving the following syntax error in GeneratedMocks.swift -> Keyword 'deinit' cannot be used as an identifier here

I've looked at the Generator code a bit and was able to reproduce this with ./runcuckoo generate test.swift (the test.swift being a simple swift class with a deinit method), however I'm not familiar enough with the way the GeneratedMocks.swift works to be sure I actually fix the problem.

I think it could be fixed in Generator.swift:86, Generator.swift:113 and by adding the isDeinit to the Token.swift class. Hope you can fix this or help me

mrgerych commented 7 years ago

@0xPr0xy check my PR. it fix deinit issue