Notes to myself about how to setup a Java repl to work with automatic JUnit tests.
First, add junit:junit from Packages
Next, redirect the “Run” button:
Create a new .replit file and add run = "bash run.sh"
Create a new shell script run.sh and add the following lines…
javac -classpath .:/run_dir/junit-4.12.jar:/run_dir/hamcrest-core-1.3.jar:/run_dir/json-simple-1.1.1.jar -d . *.java
java -classpath .:/run_dir/junit-4.12.jar:/run_dir/hamcrest-core-1.3.jar:/run_dir/json-simple-1.1.1.jar ShoesTester
# javac *.java
# java ShoesTester
Here is a sample ShoesTester file:
import org.junit.*;
import org.junit.runner.*;
import static org.junit.Assert.*;
public class ShoesTester {
public int add3(int n) {
return n+3;
}
@Test
public void test_add3() {
assertEquals(8,add3(5));
}
@Test
public void trivial_test(){
assertTrue(5 == 2+3);
assertFalse(7 != 14/2);
}
public static void main(String[] args) {
System.out.println("Hello tests!");
org.junit.runner.JUnitCore.main("ShoesTester");
}
}
Here is the TEDIOUS process to follow to convert an old Quiz Question Bank to a new Quiz Item Bank in Canvas:
This post consists of notes to myself, so that I can remember the commands to create a Node.js Twitterbot hosted on Heroku.
Create a Github repo and clone it locally
.env
.DS_Store
node_modules/
npm init
npm asks questions and builds a package.json file.
npm install dotenv
npm install twit
npm install express
CONSUMER_KEY = ...
CONSUMER_SECRET = ...
ACCESS_KEY = ...
ACCESS_SECRET = ...
const express = require('express');
const app = express();
require('dotenv').config();
const Twit = require('twit');
// const T = new Twit({
// consumer_key: process.env.CONSUMER_KEY,
// consumer_secret: process.env.CONSUMER_SECRET,
// access_token: process.env.ACCESS_KEY,
// access_token_secret: process.env.ACCESS_SECRET,
// timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
// strictSSL: true, // optional - requires SSL certificates to be valid.
// });
// yr code here
app.listen(
process.env.PORT || 3000,
()=>console.log("bot running")
);
Write your code in index.js
node index.js
CONSUMER_KEY = ...
CONSUMER_SECRET = ...
ACCESS_KEY = ...
ACCESS_SECRET = ...
git checkout -b Github_Public
git push -u origin Github_Public
Go to the website for the Github repo, click Settings > Branches, and change Github_Public to be the default branch
Commit/push the Github_Public branch. Switch to the master/main branch.
worker: node index.js
heroku login
heroku git:remote -a goodnitebot
git add .
git commit -am "make it better"
git push heroku master
RECENT POSTS