Coder Social home page Coder Social logo

mocka's People

Contributors

123go avatar larshp avatar uweku avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mocka's Issues

Method call with optional importing parameters

Hi,
I am trying out this framework and so far I think it's very neat! Exactly what has been missing in ABAP. I have one question regarding optional / default value importing parameters.
It seems that the framework will register a call only for actually passed parameters, which I think is fine. But the IS SUPPLIED condition in the generated mock method returns false for parameters with default values. I think it should be registered though, because a default parameter is always passed even if (or particularly when) there is no actual parameter.
Secondly, the HAS_BEEN_CALLED_WITH method will build a method call with all parameters, regardless whether they are optional / have default values or not, and compares this to the actual method calls that have happenend. I don't see how this condtion can ever be fulfilled if I leave out optional parameters in the actual implementation.
I hope the description of my problem is clear.. Did I miss something in the documentation (i.e. is this known / intended behaviour) or is this a bug?

Kind regards & thank you for this framework.
Max

Methods without returning parameters don't get mocked

If you call the methods
changes
exports
raises_by_name
with
with_changing

These don't get mocked.

I've added the following code
finalize_current_method_sign( ).

To the end of each method before the
ro_mocker_method = me.
statement to get this to work.

Mocking interface methods with total name longer than 30 characters doesn't work.

I am creating a mock for a class 'ZCL_RECEIVABLE_CALCULATOR_RBL' which implements an interface 'ZIF_CFSR_RECEIVABLE_CALCULATOR'. When I try to create a fake for the method 'ZIF_CFSR_RECEIVABLE_CALCULATORCALCULATE' the mock cuts the total method name off at 30 characters: 'ZIF_CFSR_RECEIVABLE_CALCULATORCAL' and generating the mock fails.

abapGit Support

Hi Uwe,

do you plan to support installation / Updating mockA with abapGit?

regards
Micha

Error during import repository

I tried to import repository with ABAPGit. But in my system occurs the error:
image
I analyzed this problem. Master language of repository is detected as DE. But in my system language is EN. Can you change default language to EN?

Private attributes aren't being correctly detected on NW7.02 EHP6

Hi

Line 175 of ZIF_MOCKA_MOCKER~GENERATE_MOCKUP checks the visibility field for a 0 to determine if the attribute is a private one or not.

On our release of SAP this value is an 'I'.

I've changed my code from

IF <ls_attribute>-visibility = 'I'."no mocking of private attributes

to

IF <ls_attribute>-visibility = 'I' or '0'."no mocking of private attributes

Thanx

Nath

Mocking classes with old style exceptions not possible

Mocking if_http_client, it seems it's actually not possible as I get an error that using old exception types isn't allowed. Methods like IF_HTTP_CLIENT~CLOSE use old exception types so the generated code cannot compile.
Old exception types are not yet supportedd, however, generating the mockup should not fail.

Proposed solution skip output of
DATA lo_cx_exc TYPE REF TO cx_root.
IF lv_exception IS NOT INITIAL.
TRANSLATE lv_exception TO UPPER CASE.
CREATE OBJECT lo_cx_exc TYPE (lv_exception).
RAISE EXCEPTION lo_cx_exc.
ENDIF.
.
in method GENERATE_MOCKUP in case the method to be mocked contains old style exceptions

Skip reusing of subroutine pool when a class needs to be mocked

Hallo Uwe,

bei einer Testkonstellation habe ich festgestellt, dass je Testklasse nur genau 1 Mock einer Klasse erzeugt werden kann.
Aufgefallen ist dies bei einer Methode ohne Parameter, die abhängig von der simulierten DB-Situation einmal true und einmal false liefern soll.
Dies hat so nicht funktioniert, da es nicht möglich ist, einen weiteren Mock für dieselbe Klasse zu erzeugen. Der bereits bestehende Mock wird recycelt (Limit Subroutine-Pool).
Wäre es möglich, das Framework schaltbar zu machen, um das Recycling zu aktivieren oder deaktivieren?
Wobei sich mir generell die Frage stellt, ob in einer Testklasse jemals mehr als 36 Mocks einer Klasse erzeugt werden müssen.


Hallo Sven,

ja, das Verhalten ist korrekt beschrieben. Bei Interfaces macht das meines Wissens nach keine Probleme, weil einfach alle Methoden implementiert werden. Handelt es sich bei deinem Testfall um eine nicht finale Klasse, deren Verhalten übersteuert werden soll?

Leider ist bei Klassen so, dass von mockA nur die Methoden redefiniert werden, die tatsächlich beim ersten Generieren zu simulieren sind.
Man könnte die Wiederverwendung der generierten Quellcodes bei Klassen generell ausschalten, was das Problem lösen würde.

An die Restriktion von 36 Mocks je Unit Test bin ich jedenfalls selbst schon gestoßen :-)

Viele Grüße,

Uwe

Registration of input patterns needs to be comparable with actual input

As of now, the ASSERT_EQUALS method in ZCL_MOCKA_VALUE_COMPARISON compares actual method input parameters with the registered parameters.
However this operation might fail as registerd parameters and actual method parameters might not be comparable. It can even cause a short dump.
The current implementation catches CX_ROOT, but comparing the values can still cause a short dump in some cases.

A check logic just like the local class lcl_Check in CL_AUNIT_ASSERT provides for ABAP Unit might be better and more error-proof.

Minor changes needed for 7.01

I found that mockA works well with 7.01 with some minor changes to the sources:

  • replace 2 occurrences of cl_abap_unit_assert with cl_aunit_assert
  • add a line to ZCL_MOCKA_MOCKER->ZIF_MOCKA_MOCKER~GENERATE_MOCKUP:

    line 35: append 'type-pools: abap.' to lt_code.


Have fun!

Function Module wrapper?

I think it would be nice to have a possibility to automatically generate function call wrappers.
Do you see a way to extend the mockA framework to be able to do this?

Cannot install using latest SAPLink

Hi

I cannot install mockA using the latest SAPLink, I've downloaded the latest daily build, but keep getting the error message::

"You have an empty nugget" everytime I try,

Regards

When running mulitple unit tests in the ATC the mock objects don't get regenerated

If you run unit tests in the ATC or by right clicking on the object and going to Execute->Unit tests

If you have multiple test methods then the mock object doesn't get regenerated for the next unit test method.

This is because the static variables

MV_MOCK_COUNT.
MT_GENERATED_CLASSES

do not get cleared down between method calls and as a result the subroutine pool doesn't get regenerated.

I've created a method FREE in the interface ZIF_MOCKA_MOCKER, which I've implemented to clear down these variables. I call this method before I leave the testing method.

This could be an artefact of being on a different system to yourself.

Thanx

Nath

Mock properties

In SCN, Ethan mentioned: Are there plans to mock properties directly? I know, it's a no-no to have public properties, but many of SAP's built-in classes use them - for example if_http_client->response.

Mock included interface methods

When mocking an interface that aliases methods from another interface (if_http_reponse aliases methods from if_http_entity), it seems you need to mock the full method from the other interface, not the aliased method. If you mock the interface method, when your code calls the alias it will get the value you mock. But if you mock the alias you get nothing, or so it seems to me.

So, if you want to mock if_http_response->get_cdata( ), you need to lo_mocker->method('if_http_entity~get_cdata')->return('Foo').
This behaviour

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.