-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
good first issue: check if assertTrue has a message argument #4307
Comments
Hey 👋🏻, I am new to open source and really excited to do something for community, can you please assign this work to me? |
@MartinWitt thank you for assigning this work to me. Can you please explain me exactly what I have to do. After reading some previous comments, I think I have to add a comment message in the code like this (message: Couldn't find path to maven home). |
Hi @NAMANIND ! First of all, thank you for volunteering to contribute! The issue is about checking if The former one is more desirable because whenever the test fails, JUnit also displays the message passed. This makes it easier for developers to debug what went wrong. In the latter case, only an Now, you need to test that for every test method which uses
To answer your question again, you just have to check if all methods which use
The above code will help you find all the |
Hi @algomaster99 ! All of them are mentioned below :-
I found several other way of using
Please see all the above things I got and tell me what to do next. |
@NAMANIND you don't need to check these test methods manually. Instead, you need to write a test suite to check if each test method follows a contract - '
There is nothing right or wrong here. Let's prefer to use desirable and undesirable. The last three test cases which you linked have |
Hey @algomaster99 I have wrote a test suite and run all the test cases. Let me explain you with an example what I found :-
Thus, How can I add missing messages to assertTrue without knowing that it is true or not because that line is not executed untill above line get execute. Although like in this example I can add a message:"file(cpe) doesn't exist" like something. Please tell me what to do in it. |
You should submit a PR for it from your fork and we can start the review process. What do you think?
I think the title of the issue may have caused this confusion. You don't have to add a @monperrus could you rewrite the issue title as "good first issue: check if assertTrue has a message argument", or something similar along those lines? |
done. |
Hi @NAMANIND! Did you make any progress? Do you need some help with this issue? |
Hey, I'm also new to open source and would like to get some experience. I've taken a look at this issue and tried to create a test file using ideas presented in this convo. I'm finding it quite difficult to access the parameters of each statement, but I was able to test if the statements direct children contained "assertTrue(boolean,java.lang.String)" . Any help/guidance would be greatly appreciated. |
Hey @Salma0104, I'm not sure if I understand how much you got so far. If you already wrote some code, it might be helpful to share it here, that way we can answer more straightforward. If you're trying to get the arguments from a method invocation, you can access them through the I'm not sure if that helps, so let me know :) |
@SirYwell thanks for the reply. After launching and building the model where the resource is the root folder mentioned |
Hi @Salma0104 ! Thanks for contributing. Your idea is correct. I have three suggestions:
Yes, that is expected. @SirYwell , any ideas on how we can ignore them for now so that we can proceed to write this test case without it failing the CI? I was thinking to add a single line comment to ignore checking for all |
I have another: Use a Processor to find all invocations. This would look like launcher.addProcessor(new AbstractProcessor<CtInvocation<?>>() {
@Override
public void process(CtInvocation<?> invocation) {
// check if it is assertTrue without a message
}
}); I believe this automatically traverses into inner classes and makes it a bit easier to check :) I'd propose the test to be marked with the meta test-annotation |
Thank you all for replys, im having a bit of trouble understanding the system and classes are there any resources that would help. |
Hi, |
@MartinWitt points out rightly that assertTrue assertions should always have a message, see #4298 (review)
It's a good Spoon exercise to write a processor to detect assertTrue without messages.
We welcome first contributors to Spoon who add missing messages to assertTrue.
The text was updated successfully, but these errors were encountered: