customstuff4
customstuff4 copied to clipboard
Unit tests
I read through them, but I still do not understand how the software is supposed to work. Good unit tests double as documentation.
Can you update to junit5 and add meaningful descriptions? "ShiftClickRuleTest.canApply" doesn't really says anything about what is the tested behavior.
This one tries to be informative, but manages to not to be that way. :/ "ModInfoTests.testIsValid_nullDependency_shouldReturnFalse"
These should be in a nested class, for readability. "test_createSubItems_search_tab" "test_createSubItems_differentTabs" "test_createSubItems_sameTabs"
Something like this is how it should look like:
Creating SubItems and adding them to
- the same tab
- different tabs
- the search tab
- a wrong tab
This issue is really gonna be my nitpick, but it really makes working with it a lot easier. Kudos, that you actually have any kind of unit test tough.
And by readability, this is what I mean:

I agree. I definitely need to work on the readability of the tests. I've updated to junit5 and going to put more effort into the tests. I'm not going to improve all existing tests just now but I'll try to work on a few of them now and then.
I started to "upgrade" them (to understand how the mod works), and at this point it's the "real meat" of it is what I can not deal with. The "plugins" folder.
Check them, and pull them if you find them good. https://github.com/Frontrider/customstuff4
I really wanna see, how could I put some scripting into it, at least have a way to run scripts on events at first.
The plugins folder contains the actual content that can be added with Custom Stuff. In your example of having a way to run a script on a event, you would register a new content type that listens to an event and runs the script. It could look like the GuiModifier content. If you've got any specifc questions, let me know.
Thinking about a slightly different approach, but I'll keep that in mind.
Thinking with the way how javascript (the chosen language) works, I'll just have an entry point, where you can run javascript where you register callbacks for the different events. Than create a custom "include" and the standard "require" function, so you can break up your code.
I do this, because nashorn, the javascript engine of the JVM compiles it to java bytecode. If I evaluated it every tick, than I would compile it every tick, which isn't efficient.
At least that's the current plan, I'll see how it turns out.
Not sure how I would do it with tile entities, but that's not in my scope right now.