# Problem with tests: test from documentation doesn't work

**URL:** <https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126>\
**Category:** Rust SDK\
**Created:** [December 12, 2022, 5:11pm UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126 "2022-12-12T17:11:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fuel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fuel/32/1677_2.png) [@fuel](https://forum.fuel.network/u/fuel)\
**Post date:** [December 12, 2022, 5:11pm UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126/1 "2022-12-12T17:11:07Z")

</div>

Hey guys! Sorry for the possibly stupid question

Trying to implement smart contract and decided to make some tests integration to start smart and fast development of the dapp.

Used [this tutorial](https://fuellabs.github.io/sway/v0.31.3/introduction/sway_quickstart.html) moving step by step I ran into a problem: my test fails because the counter is not incrementing (I left log there)

I’m changed the contract a bit: added init func, return changed value from increment func and added logs after each call and this test

Here is my repo [GitHub - chlenc/fuel-project](https://github.com/chlenc/fuel-project)

This is main.sw file [fuel-project/main.sw at master · chlenc/fuel-project · GitHub](https://github.com/chlenc/fuel-project/blob/master/counter-contract/src/main.sw)

This is my test file [fuel-project/harness.rs at master · chlenc/fuel-project · GitHub](https://github.com/chlenc/fuel-project/blob/master/counter-contract/tests/harness.rs)

Thanks!

The test

```auto
let (instance, _id) = get_contract_instance().await;
let init_result = instance.methods().init(1).call().await.unwrap();
println!("0️⃣ Init result: {}",init_result.value);
let increment_result = instance.methods().increment(1).call().await.unwrap();
println!("1️⃣ Increment result: {}",increment_result.value);
let result = instance.methods().count().call().await.unwrap();
println!("✅ Count: {}",result.value);
assert_eq!(result.value, 2);

```

make output like that

```auto
0️⃣ Init result: 1
1️⃣ Increment result: 1
✅ Count: 0

```

---

<div class="post-metadata">

**Author:** ![camiinthisthang.sway](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@camiinthisthang.sway](https://forum.fuel.network/u/camiinthisthang.sway)\
**Post date:** [December 13, 2022, 12:35am UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126/2 "2022-12-13T00:35:55Z")

</div>

Hey! Thanks for pointing this out. Your tests are correct, and it looks like you’re on the wrong version of forc. Run these and then try to rebuild and run the tests again:

`fuelup self update`

`fuelup toolchain install beta-2`

`fuelup default beta-2`

This should work 🙂

---

<div class="post-metadata">

**Author:** ![hejiao19850](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/hejiao19850/32/613_2.png) [@hejiao19850](https://forum.fuel.network/u/hejiao19850)\
**Post date:** [December 13, 2022, 12:16pm UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126/3 "2022-12-13T12:16:15Z")

</div>

I have no problem using it. It’s very easy to use

---

<div class="post-metadata">

**Author:** ![fuel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.fuel.network/fuel/32/1677_2.png) [@fuel](https://forum.fuel.network/u/fuel)\
**Post date:** [December 13, 2022, 3:45pm UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126/4 "2022-12-13T15:45:49Z")

</div>

@camiinthisthang.sway 's answer helps me to fix it, thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/fuel/original/2X/5/57d5a345cc15a64b636e0d56e042857f8a0e80b1.png) [@system](https://forum.fuel.network/u/system)\
**Post date:** [January 3, 2023, 11:46am UTC](https://forum.fuel.network/t/problem-with-tests-test-from-documentation-doesnt-work/126/5 "2023-01-03T11:46:03Z")

</div>

Closed on January 3, 2023, 11:46am UTC

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
