<p>You can use the <code>EmulatorTrace</code> monad introduced in <a href="https://youtu.be/6Reuh0xZDjY" rel="nofollow noreferrer">Lecture #4</a> for unit testing. You find examples of such tests in <a href="https://github.com/input-output-hk/plutus-apps/tree/main/plutus-use-cases/test/Spec" rel="nofollow noreferrer">https://github.com/input-output-hk/plutus-apps/tree/main/plutus-use-cases/test/Spec</a> .</p>

CC BY-SA 4.0
2022-02-13T09:34:50.787Z
Thanks Lars.
Do you perhaps want to update the broken link. I found this answer while searching for a related question.
Avatar33
CC BY-SA 4.0
2021-05-07T19:27:52.523Z
2022-10-21T02:15:28.480Z
2022-10-21T02:15:28.480Z
Lars Brünjes
<p>You can also use this <a href="https://github.com/mlabs-haskell/plutus-simple-model" rel="nofollow noreferrer">https://github.com/mlabs-haskell/plutus-simple-model</a></p>
<p>I'd say it's better because it's more up to date than the plutus-apps repo needed (for Contract Monad) from IOG (a lot is missing from Vasil)</p>

CC BY-SA 4.0
2022-10-24T08:40:40.203Z
2022-10-24T08:40:40.203Z
Cristovao Morgado
<p>I'm a member of Plutus Pioneer Program. I already know about the Plutus Playground and like it very much. However, clicking all the blockchain action scenarios each time is very time-consuming, especially that after changes in the source code the test scenario often gets wiped out.</p>
<p>It would be much better to have a framework to define and run unit tests, as well as not having to edit the code in the browser.</p>
<p>Although I'm new to Haskell, I'm pretty sure there is some unit test environment. Is it also possible to write scenarios in a file and put assertions on blockchain state, instead of clicking them in the Playground?</p>

<plutus><smart-contract><unit-test>
How can I write unit tests for Plutus contracts?
# How can I write unit tests for Plutus contracts?

(Asked by: username_0 on 2021-05-06)

I'm a member of Plutus Pioneer Program. I already know about the Plutus Playground and like it very much. However, clicking all the blockchain action scenarios each time is very time-consuming, especially that after changes in the source code the test scenario often gets wiped out.

It would be much better to have a framework to define and run unit tests, as well as not having to edit the code in the browser.

Although I'm new to Haskell, I'm pretty sure there is some unit test environment. Is it also possible to write scenarios in a file and put assertions on blockchain state, instead of clicking them in the Playground?

**Tags:** plutus, smart-contract, unit-test

---

## 2 answers

### Answer by username_1 on 2021-05-07. Score: 6 | Accepted answer

You can use the `EmulatorTrace` monad introduced in [Lecture #4](https://youtu.be/6Reuh0xZDjY) for unit testing. You find examples of such tests in <https://github.com/input-output-hk/plutus-apps/tree/main/plutus-use-cases/test/Spec> .

> **Comments:**
> **username_2**: Thanks Lars. Do you perhaps want to update the broken link. I found this answer while searching for a related question.  

---

### Answer by username_3 on 2022-10-24. Score: 1

You can also use this <https://github.com/mlabs-haskell/plutus-simple-model>

I'd say it's better because it's more up to date than the plutus-apps repo needed (for Contract Monad) from IOG (a lot is missing from Vasil)


---

