<commit_before># Introduction to fudje

The following intro is divided in 2 major sections. The first one will assume you've never heard of midje before, and will simply explain what the `mocking` macro does and how to use it (which is the whole API really). 
It will also cover how to use the checkers provided. The second section will be about automatically rewriting existing midje tests, and as such we will assume, at least some, familiarity with midje.


## Writing new tests

fudje.core basically exposes a single macro called `mocking` (it actually, exposes `in-background` as well, but that's irrelevant for now).
It looks like this:

```clj
(mocking [& mocks]
  & assertions)
```

At first glance, it sort of syntactically resembles `clojure.core/binding` & `clojure.core/with-redefs`. As you probably guessed, there can be any number of mocks in mocking vector, and any number of assertions following it. But what exactly is a mock or an assertion? If you've ever seen or written tests using vanilla clojure.test, then you're already familiar with what assertions look like.
In other words, fudje has no strong opinions regarding how you express your assertions. Your existing clojure.test assertions (based on `is` will work).

Let's look at a simplistic case...
Assume for a minute that you don't need to do any mocking (which is perfectly valid btw). You could write something like this:

```clj
(mocking [] ;; don't do that
  (is (= 4 (* 2 2))))
```
Obviously, using `mocking` with an empty vector makes little to no sense, but this will work regardless. So as said, you already know what an assertion looks like. It is an expression which somehow/somewhere is going to eventually call `is` and register either a success or a failure. You can have as many of those as you want following the mocking-vector. Let's now make things interesting and look at mocks...

### stubbing & mocking

Clojure already provides excellent facilities for stubbing (i.e. `with-redefs`). However, for *mocking* a specific function call with specific arguments, you're left on your own. This is where `mocking` comes to save the day. You can use it for either stubbing or mocking or a combination thereof. Using it for stubbing, is basically a convenience, since it allows you to skip surrounding your `mocking` expression with a `with-redefs` one.
 
 So we've already seen the syntax for `mocking`. A mock is basically a triplet like the following:
 
```
 mock-out => mock-in
``` 
<commit_msg>Update intro.md<commit_after># Introduction to fudje

The following intro is divided in 2 major sections. The first one will assume you've never heard of midje before, and will simply explain what the `mocking` macro does and how to use it (which is the whole API really). 
It will also cover how to use the checkers provided. The second section will be about automatically rewriting existing midje tests, and as such we will assume, at least some, familiarity with midje.


## Writing new tests

fudje.core basically exposes a single macro called `mocking` (it actually, exposes `in-background` as well, but that's irrelevant for now).
It looks like this:

```clj
(mocking [& mocks]
  & assertions)
```

At first glance, it sort of syntactically resembles `clojure.core/binding` & `clojure.core/with-redefs`. As you probably guessed, there can be any number of mocks in mocking vector, and any number of assertions following it. But what exactly is a mock or an assertion? If you've ever seen or written tests using vanilla clojure.test, then you're already familiar with what assertions look like.
In other words, fudje has no strong opinions regarding how you express your assertions. Your existing clojure.test assertions (based on `is`) will work.

Let's look at a simplistic case...
Assume for a minute that you don't need to do any mocking (which is perfectly valid btw). You could write something like this:

```clj
(mocking [] ;; don't do that
  (is (= 4 (* 2 2))))
```
Obviously, using `mocking` with an empty vector makes little to no sense, but this will work regardless. So as said, you already know what an assertion looks like. It is an expression which somehow/somewhere is going to eventually call `is` and register either a success or a failure. You can have as many of those as you want following the mocking-vector. Let's now make things interesting and look at mocks...

### stubbing & mocking

Clojure already provides excellent facilities for stubbing (i.e. `with-redefs`). However, for *mocking* a specific function call with specific arguments, you're left on your own. This is where `mocking` comes to save the day. You can use it for either stubbing or mocking or a combination thereof. Using it for stubbing, is basically a convenience, since it allows you to skip surrounding your `mocking` expression with a `with-redefs` one.
 
 So we've already seen the syntax for `mocking`. A mock is basically a triplet like the following:
 
```
 mock-out => mock-in
``` 

{'fraction_non_alphanumeric': 0.06649256729610285, 'fraction_numerical': 0.0016070711128967456, 'mean_word_length': 4.313767342582711, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2298799', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1248, 'n_words': 773}