# How cant I define a param using in different testcase?

**URL:** <https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342>\
**Category:** TestComplete\
**Tags:** test, testcomplete, migrated, script-tests\
**Created:** [January 13, 2025, 6:58am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342 "2025-01-13T06:58:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 6:58am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/1 "2025-01-13T06:58:32Z")

</div>

> Originally posted by **mengbinhao** on January 12, 2025

Hi there,

```
I have a TC project which has several testcase (wrote by JaveScript), I need to init a big Object before my Project, It only should be inited once, I know TC has a Event named OnTestStart executing before each testcase run, which is not suitable for my case, Does TC have a Event only trigger once like JUnit "BeforeAll" annotation?

```

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 9:26am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/2 "2025-01-13T09:26:58Z")

</div>

> Originally posted by **rraghvani** on January 13, 2025

Refer to [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/static) you can create a static class, which will be the first thing that will be called before any test scripts are run.

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 9:51am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/3 "2025-01-13T09:51:39Z")

</div>

> Originally posted by **mengbinhao** on January 13, 2025

Could you show me a simple example? After I define a static class, How do I use it?

Run static class first , then other testcase can get real-time value of Object inited by this static class?

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 9:59am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/4 "2025-01-13T09:59:26Z")

</div>

> Originally posted by **rraghvani** on January 13, 2025

There’s a number of examples shown here [https://stackoverflow.com/questions/1479319/simplest-cleanest-way-to-implement-a-singleton-in-javascript](https://stackoverflow.com/questions/1479319/simplest-cleanest-way-to-implement-a-singleton-in-javascript) which uses singleton class

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 10:12am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/5 "2025-01-13T10:12:16Z")

</div>

> Originally posted by **mengbinhao** on January 13, 2025

I know how to define static class or single design pattern, I just don’t know how to get static class value in TestCompelte

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 10:12am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/6 "2025-01-13T10:12:45Z")

</div>

> Originally posted by **mengbinhao** on January 13, 2025

I know how to define static class or single design pattern, I just don’t know how to get static class value in TestCompelte

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 10:39am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/7 "2025-01-13T10:39:57Z")

</div>

> Originally posted by **rraghvani** on January 13, 2025

Using the example shown in stackoverflow, it will be

```auto
myInstance.publicMethod1()

```

And also shown here

 ![](https://canada1.discourse-cdn.com/flex049/uploads/smartbear_prod/original/1X/915cfe7c5d24f08109683789bc6b34aaed209ae4.png)

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 11:21am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/8 "2025-01-13T11:21:14Z")

</div>

> Originally posted by **mengbinhao** on January 13, 2025

I’ll try this, Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 13, 2025, 12:23pm UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/9 "2025-01-13T12:23:59Z")

</div>

> Originally posted by **rraghvani** on January 13, 2025

It’s a bit tricky to explain, since this is specific to JavaScript coding. I suggest you try the example, and within your unit test, the first line should call,

```auto
var test = SingletonFactory.getInstance()

```

The SingletonFactory class can be stored in a different project within the project suite, and you can call this via [https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/index.html](https://support.smartbear.com/testcomplete/docs/scripting/calling-routines/index.html)

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 15, 2025, 1:03am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/10 "2025-01-15T01:03:42Z")

</div>

> Originally posted by **mengbinhao** on January 14, 2025

This works for me, Thank you ~

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [January 15, 2025, 1:04am UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/11 "2025-01-15T01:04:03Z")

</div>

> Originally posted by **mengbinhao** on January 14, 2025

This works for me, Thank you ~

---

<div class="post-metadata">

**Author:** ![system](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@system](https://community.smartbear.com/u/system)\
**Post date:** [October 7, 2026, 5:15pm UTC](https://community.smartbear.com/t/how-cant-i-define-a-param-using-in-different-testcase/342/12 "2026-10-07T17:15:49Z")

</div>

Closed on October 7, 2026, 5:15pm UTC

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