HomeBlogHow to Run Custom Scripts in NeoLoad: Setup and Best Practices

How to Run Custom Scripts in NeoLoad: Setup and Best Practices

Author

Date

Category

Running custom scripts in NeoLoad can feel a bit scary at first. There are buttons. There are code editors. There are warnings about performance. But here’s the good news: it’s not rocket science. With the right setup and a few best practices, you can run powerful custom scripts that make your performance tests smarter, faster, and more realistic.

TL;DR: Custom scripts in NeoLoad let you extend your performance tests beyond built-in features. You can use JavaScript, Java, or external programs to handle complex logic, dynamic data, and integrations. Set up your environment carefully, test scripts in isolation, and always monitor performance impact. Keep scripts simple, reusable, and well-documented.

Let’s break it down step by step. And keep it fun.

Why Use Custom Scripts in NeoLoad?

NeoLoad already does a lot. It records user paths. It handles correlations. It manages variables.

So why touch code?

Because sometimes you need more control.

  • Dynamic data transformations
  • Complex authentication logic
  • Custom validations
  • Integration with external systems
  • Advanced calculations

Think of custom scripts as your “escape hatch.” When the standard interface cannot do it, your script can.

computer screen showing code and terminal output git based cms dashboard markdown editor interface content management panel

Types of Custom Scripts in NeoLoad

NeoLoad supports different scripting options. Each has its own strength.

1. JavaScript (Built-in)

This is the easiest place to start.

  • Directly integrated in NeoLoad
  • Great for variable handling
  • Perfect for lightweight logic

You can insert JavaScript actions inside a Virtual User (VUser) path. Use it to manipulate variables or generate custom values.

2. Java (Custom Actions)

This is more advanced.

  • Full Java power
  • Great for complex integrations
  • Reusable across projects

You create a Java class. Compile it. Add it to NeoLoad as a custom action.

3. External Programs

Sometimes you want to call an external script.

  • Python scripts
  • Shell scripts
  • Custom executables

NeoLoad can execute these during a test. Just be careful about performance overhead.

Quick Comparison Chart

Option Skill Level Best For Performance Impact
JavaScript Beginner Variable logic, small calculations Low
Java Advanced System integration, complex processing Medium
External Scripts Advanced Using existing tools or scripts High if poorly optimized

If you are new, start with JavaScript. Always.

Step-by-Step: Setting Up a JavaScript Custom Action

Let’s get practical.

Step 1: Open Your Project

Go to your Virtual User scenario.

Select the action where you want custom logic.

Step 2: Add a JavaScript Action

Right-click in the user path.

Choose Add → JavaScript Action.

Step 3: Write Your Code

Simple example:

var timestamp = Date.now();
context.variableManager.setValue("myTimestamp", timestamp);

This creates a dynamic variable. Clean. Simple.

Step 4: Validate

Always test with:

  • Debug mode
  • Low user count
  • Log inspection

If it works with 1 user, then scale slowly.

blue and white visa card on silver laptop computer online payment screen credit card laptop close up 1

Setting Up Java Custom Actions

This takes more work. But it is powerful.

1. Install JDK

Make sure Java is installed.

Match NeoLoad’s supported version.

2. Create a Java Project

Use your favorite IDE:

  • IntelliJ
  • Eclipse
  • VS Code

Add NeoLoad’s API libraries to your classpath.

3. Implement the Action Interface

Your class must follow NeoLoad’s custom action structure.

Override required methods.

Handle exceptions safely.

4. Build a JAR File

Export as a JAR.

Import into NeoLoad.

5. Add to User Path

Now it behaves like a standard action.

But with superpowers.

Best Practices for Running Custom Scripts

This is where many people fail. Not in writing code. But in running it safely during load.

1. Keep Scripts Lightweight

Remember this:

Your script runs for every virtual user.

Heavy logic × 1000 users = trouble.

Avoid:

  • Expensive loops
  • Huge file reads
  • Complex object creation

If logic is heavy, precompute it before the test.

2. Avoid Blocking Calls

Do not call slow APIs from inside scripts.

Why?

Because you are testing your system. Not your helper script.

Blocking calls distort results.

3. Use Variables Smartly

NeoLoad variables are powerful.

  • Store computed values
  • Pass data between steps
  • Log intermediate results

Give variables clear names.

Bad: x1

Good: userAuthToken

4. Log Carefully

Logging is useful.

Too much logging is dangerous.

Under high load, excessive logs slow everything down.

Use debug logs only during testing. Disable them for real load tests.

5. Handle Errors Gracefully

Your script should never crash the entire test.

Use:

  • Try-catch blocks
  • Meaningful error messages
  • Fallback logic if possible

If one VUser fails, others should continue.

6. Version Control Your Scripts

This is often ignored.

Store all custom scripts in:

  • Git
  • SVN
  • Any version system

Why?

Because performance issues sometimes come from script changes.

No version history = no root cause analysis.

Performance Impact: What to Watch

Custom scripts consume CPU and memory.

Especially under load.

Monitor:

  • Load generator CPU usage
  • Memory usage
  • Error rate spikes

If CPU hits 100%, your script might be too heavy.

Do a test:

  1. Run without script.
  2. Run with script.
  3. Compare resource usage.

This isolates impact.

a close up of a text description on a computer screen web browser task manager high cpu usage graph multiple processes list

Security Considerations

Scripts can expose sensitive data.

Be careful with:

  • Passwords
  • API keys
  • Tokens

Never hardcode secrets.

Store them securely. Use environment variables when possible.

Mask sensitive logs.

Common Mistakes to Avoid

Let’s save you some headaches.

Writing Complex Business Logic

NeoLoad is for testing load.

It is not your application server.

Keep business logic minimal.

Ignoring Script Testing

Test scripts separately.

Do not wait until full load to discover bugs.

Forgetting Thread Safety

Each VUser runs independently.

Avoid shared static variables in Java custom actions.

Thread issues are sneaky.

Overusing External Scripts

Calling external processes for each user is expensive.

If possible, move logic inside NeoLoad.

Pro Tips for Cleaner Scripting

  • Write small reusable functions.
  • Document what the script does.
  • Name files clearly.
  • Review scripts with teammates.
  • Benchmark periodically.

A clean script today saves you hours later.

A Simple Mental Model

Think of NeoLoad like a movie set.

The VUsers are actors.

The script is the director whispering instructions.

If the director whispers simple guidance, the movie runs smoothly.

If the director shouts complex math every second, chaos happens.

Keep your director calm.

Final Thoughts

Running custom scripts in NeoLoad is not about showing off coding skills.

It is about enhancing realism.

It is about making your tests smarter.

Start simple.

Use JavaScript first.

Measure performance impact.

Scale carefully.

Document everything.

When used correctly, custom scripts turn NeoLoad from a strong tool into a powerful testing engine.

And now, you’re ready to use it like a pro.

Recent posts