Cute-Test / cdt-plugin

Eclipse CDT integration of the CUTE Unit Testing Framework
Eclipse Public License 2.0
0 stars 1 forks source link

Mockator throws exception "java.lang.reflect.invocationTargetException" #1

Open JoergMoeller opened 5 years ago

JoergMoeller commented 5 years ago

Expected Behavior

Converting a C function into a Mock function liked described here https://www.cute-test.com/guides/mocking-with-cute/#mockfunctions

Actual Behavior

Setup: Software under Test: C++ Static Libraray, C++ 11, name: SUT Test Code: Cute Project, Cute Project, C++ 11, name: testSUT, linked to SUT project

1.) Problem: After selecting C function from SUT code ( myfunc ) and selecting "Source / Mock Function", the dialog "New Cute Suite File" pops up. After naming the new test suite "xyz" and selecting "Link to runner" it doesn't provide a runner, though one is present.

2.) Problem: After hitting the "Finish" button it throws an expecetion "java.lang.reflect.InvocationTargetException". No files are created.

CUTE or CUTE Eclipse Plug-in Version, Operating System and Compiler

I've attached a zip archive of the Workspace, the error log file and screenshots of the error message.

I've also tried with the latest CEvelop version, 1.10.1 Release, with the same behaviour.

Cute_ErrorLog.txt

cute_errordialog

cute_installedsoftware

MockatorBug.zip

If you need more information I'll happily provide it.

Regards Joerg

PeterSommerlad commented 5 years ago

Have you tried to compile/parse the .c file as C++? Internally the C-AST and the C++-AST differ and for plug-ins like Mockator that we do not push upstream to Eclipse-CDT we usually only implement features for C++. If you want to know why, send me an email.

either rename sut.c to sut.cpp or set the file type .c to be C++ code and try again.

tcorbat commented 5 years ago

Thanks for the detailed report! That is very helpful to reproduce the problem. Even though we don't specifically to aim for C support, we should handle error cases more gracefully than just throwing exceptions. We'll look into it. Maybe with the correct abstration on the code representation we might get it to work with C easily.

Best Regards Thomas

JoergMoeller commented 5 years ago

Hello,

thanks for the quick reply. Actually we are developing C Code for embedded automotive ecus, so there’s little possibility to change the SUT.c to SUT.cpp so either suggested won’t work.

Regards Joerg

Sitz/Registered Office: Berlin Registergericht/Registration Court: Amtsgericht Charlottenburg Registernummer/Company Registration Number: HRB 21 280 Geschäftsführer/Managing Directors: Dr. Ulrich Eichhorn (Vorsitzender/Chairman), Matthias Kratzsch, Katja Ziegler, Kai-Stefan Linnenkohl

Von: Peter Sommerlad notifications@github.com Gesendet: Dienstag, 29. Januar 2019 10:30 An: Cute-Test/Issues Issues@noreply.github.com Cc: Moeller, Joerg (TP-E) joerg.moeller@iav.de; Author author@noreply.github.com Betreff: Re: [Cute-Test/Issues] Mockator throws exception "java.lang.reflect.invocationTargetException" (#3)

Have you tried to compile/parse the .c file as C++? Internally the C-AST and the C++-AST differ and for plug-ins like Mockator that we do not push upstream to Eclipse-CDT we usually only implement features for C++. If you want to know why, send me an email.

either rename sut.c to sut.cpp or set the file type .c to be C++ code and try again.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Cute-Test/Issues/issues/3#issuecomment-458469478, or mute the threadhttps://github.com/notifications/unsubscribe-auth/As1DO1yZ_geETmAtRANkurzfU0099Jq0ks5vIBSogaJpZM4aVQBr.

JoergMoeller commented 5 years ago

Hello,

actually the CUTE stuff is cool. We are really interested in using it. We also have a problem with installing the Example project. It’s also throwing exception. Do you want me to create another ticket for it? It’s the same behavior in Cute and Cevelop.

Regards Joerg

Sitz/Registered Office: Berlin Registergericht/Registration Court: Amtsgericht Charlottenburg Registernummer/Company Registration Number: HRB 21 280 Geschäftsführer/Managing Directors: Dr. Ulrich Eichhorn (Vorsitzender/Chairman), Matthias Kratzsch, Katja Ziegler, Kai-Stefan Linnenkohl

Von: tcorbat notifications@github.com Gesendet: Dienstag, 29. Januar 2019 11:11 An: Cute-Test/Issues Issues@noreply.github.com Cc: Moeller, Joerg (TP-E) joerg.moeller@iav.de; Author author@noreply.github.com Betreff: Re: [Cute-Test/Issues] Mockator throws exception "java.lang.reflect.invocationTargetException" (#3)

Thanks for the detailed report! That is very helpful to reproduce the problem. Even though we don't specifically to aim for C support, we should handle error cases more gracefully than just throwing exceptions. We'll look into it. Maybe with the correct abstration on the code representation we might get it to work with C easily.

Best Regards Thomas

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Cute-Test/Issues/issues/3#issuecomment-458483186, or mute the threadhttps://github.com/notifications/unsubscribe-auth/As1DOx4slURlcM9nt6BdRG3HvX_4q8OLks5vIB5QgaJpZM4aVQBr.

PeterSommerlad commented 5 years ago

You do not need to change the .c, just make Cevelop/Eclipse-CDT into parsing it as C++ for a try (settings->file types-> project-specific...

pipeaesac commented 5 years ago

Hello Joerg,

I looked at your problem more closely and was able to reproduce the issue. I also checked the behaviour in a similar scenario but using a C++ project instead of a C project. In that case, the refactoring worked as expected.

In the upcoming release of CUTE, we fixed the issue in the UI, where we disable the checkbox for the runner selection when no runners are present. This prevents the issue with the java.lang.reflect.invocationTargetException.

However, adding C support to the refactoring requires large scale changes to the plugin and is therefore not planned for the near future.

Best Regards Mario

JoergMoeller commented 5 years ago

Hello,

I#ve tried what you proposed, but I’m not sure if I understand correctly. Here’s what I was trying to achieve:

[cid:image001.png@01D4BD2A.D2CA33D0]

Unfortunately it seems that I can’t change the file type. Maybe I’m at the wrong place?

Regards Joerg

Sitz/Registered Office: Berlin Registergericht/Registration Court: Amtsgericht Charlottenburg Registernummer/Company Registration Number: HRB 21 280 Geschäftsführer/Managing Directors: Dr. Ulrich Eichhorn (Vorsitzender/Chairman), Matthias Kratzsch, Katja Ziegler, Kai-Stefan Linnenkohl Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board: Prof. Dr. Stefan Gies

Von: Peter Sommerlad notifications@github.com Gesendet: Dienstag, 29. Januar 2019 11:19 An: Cute-Test/Issues Issues@noreply.github.com Cc: Moeller, Joerg (TP-E) joerg.moeller@iav.de; Author author@noreply.github.com Betreff: Re: [Cute-Test/Issues] Mockator throws exception "java.lang.reflect.invocationTargetException" (#3)

You do not need to change the .c, just make Cevelop/Eclipse-CDT into parsing it as C++ for a try (settings->file types-> project-specific...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Cute-Test/Issues/issues/3#issuecomment-458485521, or mute the threadhttps://github.com/notifications/unsubscribe-auth/As1DO0cKTgzdaHXRGlx4gSom7cp81uTxks5vICAWgaJpZM4aVQBr. c_parser

JoergMoeller commented 5 years ago

Hello,

thanks for the feedback and your effort in resolving the issue. Actually we don’t expect full refactoring capabilities. We would very much appreciate if “mock function” would work with plain C code.

Kind Regards Joerg

Sitz/Registered Office: Berlin Registergericht/Registration Court: Amtsgericht Charlottenburg Registernummer/Company Registration Number: HRB 21 280 Geschäftsführer/Managing Directors: Dr. Ulrich Eichhorn (Vorsitzender/Chairman), Matthias Kratzsch, Katja Ziegler, Kai-Stefan Linnenkohl Vorsitzender des Aufsichtsrates/Chairman of the Supervisory Board: Prof. Dr. Stefan Gies

Von: Mario Meili notifications@github.com Gesendet: Montag, 4. Februar 2019 12:54 An: Cute-Test/Issues Issues@noreply.github.com Cc: Moeller, Joerg (TP-E) joerg.moeller@iav.de; Author author@noreply.github.com Betreff: Re: [Cute-Test/Issues] Mockator throws exception "java.lang.reflect.invocationTargetException" (#3)

Hello Joerg,

I looked at your problem more closely and was able to reproduce the issue. I also checked the behaviour in a similar scenario but using a C++ project instead of a C project. In that case, the refactoring worked as expected.

In the upcoming release of CUTE, we fixed the issue in the UI, where we disable the checkbox for the runner selection when no runners are present. This prevents the issue with the java.lang.reflect.invocationTargetException.

However, adding C support to the refactoring requires large scale changes to the plugin and is therefore not planned for the near future.

Best Regards Mario

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Cute-Test/Issues/issues/3#issuecomment-460221837, or mute the threadhttps://github.com/notifications/unsubscribe-auth/As1DO_3WpIx9gYVdcD8CMiFxJzdwIJkrks5vKB9pgaJpZM4aVQBr.

PeterSommerlad commented 5 years ago

Unfortunately, Mockator relies on the foundation of C++ refactoring and thus 'just' means a lot of work, because as said above the C language representation within Eclipse CDT is separate from C++.

I could not see the image showing what you tried with my suggestion. Could you upload the screenshot directly to github instead of replying to the email notification?