sixty-north / cosmic-ray

Mutation testing for Python
MIT License
565 stars 57 forks source link

how to only mutate the code but do not run test? #494

Closed Marvinmw closed 3 years ago

Marvinmw commented 4 years ago

Hi, I am testing a projec that has its own test framework. I only want to generate the mutants. and then I will write a wrapper to run all the mutants for that specific test framework. How to do it?

boxed commented 4 years ago

I believe CR doesn't support this use case. Mutmut on the other hand does. You judt specify the runner and you should be good to go.

abingham commented 4 years ago

I'm not entirely sure what you want. If you've got a custom test running command of some sort, you can set the test-command field in your configuration to run it. CR will run it for each separate mutation, treating 0 exit codes as success (i.e. no failures). Based on your description, it sounds like this is what you want to do; the wrapper you want to write sounds like the cosmic-ray exec command.

If you want to generate a specific mutation on disk (i.e. without any cloning of workspaces or anything like that), you can use the apply command. This simply makes the mutation to your code and does nothing else. It's up to you to decide what operator to use, etc.

If you need something else, then I misunderstand. Could you clarify?

boxed commented 4 years ago

Ah. Nice to see cosmic ray supports this use case now!

abingham commented 4 years ago

We've supported arbitrary test systems almost from day one. It used to rely on a plugin system, but the test-command approach seems just as effective (and much simpler) in practice.

If you mean making individual mutations on disk, we've technically supported that for a long time as well, but I've only recently decided it was a reasonable public-facing feature.

boxed commented 4 years ago

I thought you used to mutate in memory with an import loader and thus had to have plug-ins for all testers? Or maybe that's what you meant?

abingham commented 4 years ago

Right, the original in-memory approach made some awkward requirements on the test system; it was based on what systems like unittest and pytest could do. Even back then, though, I think I had a way to write individual mutations to disk for debugging...my aging mind can't reach that far back into history!

boxed commented 4 years ago

I think you butchered the file in that case since you didn't use baron like I did in the beginning with mutmut, or parso like we both use now. Parso is really awesome I think is the conclusion :)

abingham commented 4 years ago

Yes, parso is nearly magical.

On Wed, Nov 27, 2019, 11:19 Anders Hovmöller notifications@github.com wrote:

I think you butchered the file in that case since you didn't use baron like I did in the beginning with mutmut, or parso like we both use now. Parso is really awesome I think is the conclusion :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sixty-north/cosmic-ray/issues/494?email_source=notifications&email_token=AAATK6F7DGDAOG7RWIG43S3QVZCRLA5CNFSM4JR5EH4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFJAQ6A#issuecomment-559024248, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAATK6HSNBSUAQP5YBW2LXTQVZCRLANCNFSM4JR5EH4A .