Skip to content
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

How to run test files in package structure? #21

Open
synchi opened this issue Apr 24, 2020 · 6 comments
Open

How to run test files in package structure? #21

synchi opened this issue Apr 24, 2020 · 6 comments

Comments

@synchi
Copy link

synchi commented Apr 24, 2020

Hi,

Generating the mutants works perfectly well when my source code is under a package structure, as instructed by MuJava documentation. But, only test files in the root testset directory are visible to MuJava - it will not run the tests under a package structure. When I flatten all the test files out of their directories, MuJava still won't work because of the package definitions mismatching the files. I've now tried refactoring the entire project to be flat (fixing things such as nested imports which require a package), as flattening only the tests and refactoring everything to work turned out too tedious. I hope it will now succeed - but I have many more projects to set up with MuJava, and I feel like this is not the right way to go...

Is there any way to make MuJava (MuScript) run the test files in a package structure, just like the source code?

If this is not available, could you point me to where MuJava's code should be modified please?

Many thanks,
Sara

@winonecheng
Copy link

In my opinion, mutation tool is not suitable for large project.
Do mutant in code snippet or little program.

@synchi
Copy link
Author

synchi commented Apr 30, 2020

Thanks for your reply @winonecheng.
I would like to use MuJava for my thesis research using a variety of standard Java projects. MuJava provides the flexibility I need, therefore I hope this feature to be a possibility. Do you have any suggestions on how to configure or implement this for MuJava?

@winonecheng
Copy link

could u show your project structure?

@synchi
Copy link
Author

synchi commented Apr 30, 2020

@winonecheng For example: https://github.com/apache/commons-lang
Just a standard src/main/java/org/etc structure, where the java files under /java (so starting with org) are placed in MuJava's src folder. I've compiled the project and placed the entirety of the class files, in their original package structure, from the target folder (instead of the src folder, and starting from org) into MuJava's classes folder. This perfectly allows for generating mutants. Then ideally, I'd like to place the entirety of subdirectories in target/test-classes/org into MuJava's testset, but MuJava won't run the tests under the subdirectory structure.

@winonecheng
Copy link

Ok, I see. Because MuJava cant run multiple test files in the same time (one command), you have to merge all test cases into single file and refactor the project. It takes a lot of work.
If only MuJava supported CLI, you could write a simple script to run through your test files.

Since you can generate the mutants, its not hard to use a script to run all junit test cases and all mutants.
Hope it will be helpful to you 👍

@synchi
Copy link
Author

synchi commented Apr 30, 2020

@winonecheng Exactly, I attempted flattening and refactoring the project, and got it running (kind of, it exited with an exception). But due to the nature of my research, this is not going to be a feasible approach.
I do use MuScript, MuJava's CLI version. https://cs.gmu.edu/~offutt/mujava/muscript/
I was indeed considering finding a way to automate the process myself, I'll think about that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants