-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbols are not stored in the SlimTestContext #52
Comments
They are currently not stored in the slim test context but in fitnesse If I create a symbol using "let", it's not available in another fixture, — |
Yes, not ideal. A lot of the standard Slim fixtures like the script one, have built in the ability to use the Test Context. If I want to pass variables back and forth, I end up having to write code to simply move them around. Wouldn't it be better if, when running in Slim mode, RestFixture used the same mechanism? |
I agree... But i won't implement it unless there's high demand for this feature. On Feb 5, 2013 10:08 AM, "Adrian Smith" notifications@github.com wrote:
|
Please re-open if necessary. Unless there's demand for this feature I won't do it |
so what is the work-around to be able to use the variables in the rest fixture and make it available on slim fixtures? I too am trying to see if I can get the value....... |
Hi @smartrics I am looking at the code, both RestFixture and FitNesse, and I am under the impression that the issue with symbols would be into FitNesse rather than into RestFixture. What I am meaning: we should not use "let" to set values in variables but instead rely on Slim symbols as explained in http://www.fitnesse.org/FitNesse.UserGuide.WritingAcceptanceTests.SliM.SymbolsInTables (let can still be useful as temp variables in the table to decompose a check of the extraction of a value) But that does not work because FitNesse passes the symbols to the fixture, which looks to me as something dumb. FitNesse could replace referenced symbols with their values before passing the text to the fixture, and also remove any symbol assignment text. I'll give it a try but it looks like doing so would enable to use symbols in RestFixture (and any custom fixture, for that matter, including my hash fixture introduced in iisue #110). I'll go even further, a quick look suggests a slightly off design there in FitNesse, because the other fixtures included in FitNesse appears to handle the symbol stuff all by themselves. It would make sense to factor this behavior (substituting referenced symbols with their value, assigning symbols) in the runner rather than in each fixture implementations. But maybe I'm wrong, I should have a closer look at all fixtures before claiming so... I'll try hacking FitNesse to see if it enables the symbols into the custom fixtures. From there, I'll have to see if that actually make sense and talk about it on FitNesse's GitHub... :-) What do you think? |
Hey there, I got something working. The following test works using the hack of FitNesse I suggeted: (DummyFixture simply returns the content of the first column in the second colum, as a way to perform tests oustide of RestFixture) !define TEST_SYSTEM {slim} !path dependencies/* |import| | Table: Rest Fixture | http://localhost:8070 | |Table: Dummy Fixture| |Table: Dummy Fixture| | Table: Rest Fixture | http://localhost:8070 | --> $V and $Y are assigned Does that look right to you? I'll bring the issue over FitNesse to see if what I changed makes sense. Maybe I misunderstood something in the design of FitNesse/Slim. In any case, this requires no change in RestFixture! Thanks again. |
Hi - well done for the progress. Preamble. Wherever possible the my approach has always been:
With that in mind, I did look at refactoring smartrics.rest.fitnesse.fixture.support.Variables to handle either fit.FitSymbol or fitnesse.slim.VariableStore. that way the RestFixture encapsulates the two differences. So, Your proposal is more elegant even if it breaks the fit<->slim interop i was trying to achieve. Of the picture above am not sure why the output in grey is html formatted. is it supposed to be that way? |
Hi - i have closed #110. Let's keep this one open as more pertinent to the problem we're trying to solve. |
Yes in the picture the output in grey is HTML because it is the content of $V, which has been assigned the response body (HTML) of the first Rest call. FitNesse does a clean job in showing that: "$V <- [...]" As for using VariableStore, I saw you started thinking about it with a VariableStore field, not used anywhere. But I don't see any way it could work... Unless I missed something, VariableStore is purely local. So using a VariableStore in RestFixture would maybe enable to share symbols between several RestFixture calls (as I believe you did some time ago with local 'let' variables) but not shared with other fixtures. I tried looking at how FitNesse and the Slim fixtures interacts, but I could not see how FitNesse would provide any variable store to the Slim fixtures, and I did not see either any static call that could be made from the Slim fixtures to get some shared variable store (which is good design, by the way). We could always do it using stack trace and reflexion of course, but I am pretty sure we don't want to go this way... ;-) So basically RestFixture has currently no way to understand symbols defined by other fixtures, nor to define symbols for the other fixtures. Again, unless I'm wrong and missed something. From there, my conclusion is that either the Slim Fixture contract needs to be changed to provide the variable stores to the Slim fixtures, or the symbols are meant to be handled by FitNesse/Slim server only. Which led to my proposal, by replacing the symbols at the Slim server level and removing the symbol assignment text provided to the fixture (since the fixture could not use this info anyway, not having access to the symbols). I believe this may be what the FitNesse guys had in mind, since the symbol assignment stuff is already done in TableTable. It's a bit weird then that the symbol replacement was not there, and passing symbols to fixtures without access to the store of symbols do not make sense. I'll share the link to the FitNesse issue I'll create about the subject and see how it goes. Also, sorry to break the compatibility between Fit and Slim :-) |
Yeah as I remember the approach was to access the VariableStore instance But I see what you are saying and even that approach requires a change to Well then over to you and the fitnesse team.
|
Hey, I resumed my work on the hash fixture, to stumble on some HTML code! You were right, something is wrong there. Sorry to dismiss your insightful comment! Looks like I must do a slightly different code in FitNesse so that what is put in the variable is the text content, not the formatted content. |
The request on FitNesse's GitHub: unclebob/fitnesse#604 |
About the HTML code that is stored in the variable, it seems it is added by RestFixture to provide a nice pretty-print. Of course when we want to set this in a symbol, that's not what we want. Two options I see there:
So far I'm more for option 1. What do you think? |
Actually, I am not sure if it makes sense to always disable pretty printing. The assignment case is only restricted to the "report" cell. Right now I have been able to do what I wanted by hacking FitNesse and RestFixture. The question is: how to do it without hacking... I guess we'll have to solve how FitNesse handles slim symbols first, we'll see if something needs to be done with RestFixture after that. |
i agree - a property to disable pretty printing is too draconian. Maybe tag of some sort to override the "do not pretty print" on a cell by cell basis. | !- $V= -! | |
After reading related issue in FitNesse's GitHub, it becomes clear that my solution is not OK. The problem is that I proposed handling the symbols at the level of TableTable, which processes the whole table result provided by RestFixture. That means that symbols asigned in a given row, won't be replaced in the following rows. So this must definitely be handled by RestFixture, with FitNesse giving access one way or another to the symbols store. |
notwithstanding it's a horrible hack, i wonder if you could do a Map Fixture that just copies the value. |RestFixture| ...bla bla... | |DT:export labels to slim symbols| package smartrics.rest.fitnesse.fixture.support; public slimSymbol() { |
That's an interesting suggestion! However, following discussions on unclebob/fitnesse#525 I'm told there would be a way for RestFixture to store its symbols in the shared symbols table. So we could implement your grand vision of a common syntax between FIT and SLIM, with 'let' putting the symbols in the shared symbols table. I'll check out if that's actually working and maybe I'll do something for RestFixture on this basis. In any case I believe that would still not be perfect so we'll see if something is to be changed on FitNesse side anyway. |
I was going to say, that maybe that new fixture should be implemented as a fix for now. And if there is a better alternative that both restfixture and fitnesse could agree on, then use that but still make the map fixture as an alternative. |
Hi alvillaflor, If you are currently blocked and needing an urgent solution, I can share the hacks of FitNesse and RestFixture that I did. Using them, you'll be able to do '$V=' in the last column of 'let' rows. Unfortunately I don't know how I can share the files... JP |
Hi JP. not really blocked, just thinking that having 2 solutions as an end result is better than having none at all. |
@alvillaflor you can copy/paste the code above, fix it if necessary, and create the fixture yourself. It doesn't have to be in the RestFixture package for it to work. |
@smartrics I have tested RestFixture implementing StatementExecutorConsumer, and it works: setStatementExecutor(StatementExecutorInterface) gets called on RestFixture, providing a hook on the runner environment. However to make it work fully it needs "get" (there is only "assign" for now, on the latest FitNesse) so we'll have to add it in FitNesse before we can use it properly in RestFixture. Just so you know, I have started refactoring RestFixture to include this: abstract the "Variables", and make it created by some factory depending on Slim/Fit runner type and providing access to the Slim execution environment (there is no static access, contrary to Fit Fixture environment). So don't bother to do it. I'll do a Pull Request about the subject. :-) |
Fantastic! well done and thanks a lot On 3 February 2015 at 07:54, Jean-Pierre Lambert notifications@github.com
Regards, Fabrizio |
great! that is good news. Hopefully, it does not take very long. Would that change be the same as what smartrics mentioned above? Or is there something I can use now to use with slim instead of fit to make it work like the table below? |DT:export labels to slim symbols| |
I took a second look at smartrics's last snipper, and I don't believe it would work. Because that would store values in Fixture, which is only used in FIT. Using SLIM, things are much less straightforward to access to the table of symbols, and is currently not implemented in RestFixture. With the changes I will propose in a pull request, RestFixture will have proper access to the table of symbols, and thus will be able to assign values into the pool of variables shared with other fixtures. Currently this is not the case: variables assigned in RestFixture are in a local store and can be used in following RestFixture calls, but not in other fixtures. However to have the fix complete, RestFixture should not only be able to assign values in the table of symbols, but also to read values from it. This is not possible at all currently, and will be the subject of the pull request I will propose to the FitNesse guys. That way, using RestFixture will work the same in both FIT and SLIM. If you are stuck and need a quick and dirty work around, I can share my small patches that make FitNesse handle it instead of RestFixture, that I mentioned in my previous message. With it I can write this kind of thing in SLIM: |Table: Rest Fixture|http://localhost| |Table: Hash Fixture|SHA-256| |Table: Rest Fixture|http://localhost| |
cool. that would be good. thanks |
Just to tease you, using my local changes to FitNesse and RestFixture it seems to work as expected: (not shown in the screenshot, we are using SLIM here) Please note, that using "$id=" in the last cell of the 'let' won't work, the same as it does today, because RestFixture will try to match the text. We could implement some change there to detect this case properly, and set the table of symbol in that case. (not only on 'let' variables) I'll make the FitNesse pull request as soon as possible. |
thinking about that. if you do it that way. |
Yes that's how Slim symbols are supposed to work. You can have a look at FitNesse's documentation on Slim symbols. At least, that's how it works for instance on Decision Tables. I guess it would make sense to have the same behavior on TableTable custom fixtures, even though in practice it is entirely up to the implementor of the fixture. By the way, you can see that FitNesse will format the result as "$V<-[value]" even if the underlying fixture did not assign anything to $V. |
I'll make the pull request ASAP so that people can work around the issue using the branches of FitNesse and RestFixture pull requests. Better than to share dirty patches. |
Hi, you'll find the pull request here: #114 If you want to try it out, you'll need my other pull request about FitNesse: unclebob/fitnesse#644 I hope my pull request is fine, I had some troubles with my early GitHub setup, lost some code and had to rewrite it. |
I will try and merge this pull request in a branch of the RestFixture and merge only when the FitNesse patch is successfully pulled. |
Thanks. I hope I did not twist the existing code! |
Hi JP. I am searching around the web and found this implementation from 'Gregor Gramlich'. How different is his implementation from yours? url: https://groups.yahoo.com/neo/groups/fitnesse/conversations/topics/20571 I started a branch of Rest Fixture two years ago, that contains a new subclass RestScriptFixture of RestFixture. It allows to use the Fixture in a normal Slim Script table and thus also for Scenarios and the common way of Slim Symbol usage. The usage can be seen especially in this commit: Here's some more explanation of the intent I do not know, how easy it is to merge with Fabrizio's current master, but maybe someone of you finds it useful and wants to give it a try. Gregor |
:-D thanks for the compliment darthwangusa, but RestFixture is the work of smartrics! Actually I am an all new user and very minor contributor of RestFixture :-) I'll let smartrics answer to your question, but I want to add this: The project which we are testing is actually made in PHP, and as much RestFixture has been useful early on to play with the Rest API, we are now moving forward to PHP-only fixtures since we need to master carefully the data in database before making the Rest API calls, and since we can't mix PHP and Java fixtures in the same FitNesse test run. So we are thinking seriously about making a PHP alternative to RestFixture, though it will probably be less advanced while providing other features specific to our needs (like checking that a given JSON response body matches a specific JSON schema). However I don't think we'll use the same syntax than RestFixture. I think we'd rather make a ScriptTable fixture, which look like it would do the job very well for less work than making a TableTable fixture. I understand this is what proposed Gregor Hamlich. Indeed following the ScriptTable fixture adds the convenience of Slim symbols working already, and the ability to make scenario out of them to be used in other tests. |
Hey @smartrics, have you seen that my Pull Request have been merged in FitNesse? I'm not sure to understand when they do release new versions, but basically that means we can work on my Pull Request for RestFixture as soons as a new release is available. |
Thanks for your work on this @jplambert |
JP - thanks for the heads up... I will keep an eye on the next release. |
Thanks guys, Good idea @smartrics to chgange the version number. You can also explain somewhere that if people get some MethodNotFoundException about the StatementExecutorInterface#getSymbol(String) method then it is certainly because they upgraded RestFixture but not FitNesse. Please let me know how the merge of my PR with RestFixture goes, do not hesitate to ask help or to comment anything about the PR. |
Closing this issue - fix available in v 4.0 |
JP, Thanks for the contribution! |
Thanks @smartrics I did it gladly. However I just noticed that I forgot an old 'TODO' in the code that should be removed not to induce into error future maintainers. I put a review comment on SlimVariables to point it out, can you see it? |
OK - np - I'd appreciate if you patch the master branch and send a patch or a new pull request. i assume it's not going to require a new release? |
HI @smartrics just made the Pull Request #119 for this minor change. Indeed it does not require any new release, as it is just about removing an unhelpful comment. I have a question however about the releases. I believe before release 4.0, RestFixture was at 3.2. Still I can't see any 3.2 release in https://github.com/smartrics/RestFixture/releases in case people do not want to move to 4.0 (yet). That was exactly what we had at work: release 4.0 broke the setup script but we had not easy way to stay on 3.2 :-) |
Thanks! I have never released 3.2 because it became 4.0 with your pull request. Although I had the pom version to 3.2 for a while - so you must have had a version that you built from master branch |
Hi. I pulled both the 4.0 version and the latest fitnesse version that would support the changes and now the 'let' call in the script is failing. Also JP. can you please provide a small snippet here on how to use that change? |
and an example is at the end of this file in RestFixtureLiveDoc |
I have a question, what about if there is some "normal %" in my URL ? Like in an encoded url ?
This generates a NullPointerException
|
Ok thanks for reporting I will fix it
|
If I create a symbol using "let", it's not available in another fixture, say a slim script fixture, as the variables are stored in a different place?
The text was updated successfully, but these errors were encountered: