# How to write fuzz tests for a function which generates a dictionary?

**URL:** <https://discourse.elm-lang.org/t/how-to-write-fuzz-tests-for-a-function-which-generates-a-dictionary/6669>\
**Category:** Learn\
**Created:** [December 26, 2020, 2:55pm UTC](https://discourse.elm-lang.org/t/how-to-write-fuzz-tests-for-a-function-which-generates-a-dictionary/6669 "2020-12-26T14:55:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![hanifhefaz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/hanifhefaz/32/3094_2.png) [@hanifhefaz](https://discourse.elm-lang.org/u/hanifhefaz)\
**Post date:** [December 26, 2020, 2:55pm UTC](https://discourse.elm-lang.org/t/how-to-write-fuzz-tests-for-a-function-which-generates-a-dictionary/6669/1 "2020-12-26T14:55:33Z")

</div>

Hello Everyone,

I have a function called **wordsDict** , which generates dictionary or a list of dictionaries from some strings, for each of its word. I have designed some tests and they work fine.

the function is:

```
wordsDict : List String -> List Dict String Int
wordsDict =
List.map (tokenize >> toHistogram)

```

for example, the test:

```
test "test making dictionary from the data with two sentences." <|
            \() ->
                let
                    dataText =
                        ["test", "testing"]
                in
                Expect.equal [Dict.fromList [ ( "test", 1 )], Dict.fromList [( "testing", 1 )] ]
                    (dataText |> Main.wordsDict)

```

This test runs and passes as expected.

Now if I understand it clearly, fuzz testing is used to randomly give the input a 100 times with different strings.

How can I implement a fuzz test for this function? Will fuzz testing change these two strings?  
` ["test", "testing"]`

Thank You.

---

_[View the full topic](https://discourse.elm-lang.org/t/how-to-write-fuzz-tests-for-a-function-which-generates-a-dictionary/6669)._
